-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(jupyter): Fix initial viewport sizing and React 18 migration #3253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,8 @@ function App() { | |
| const resizeDelay = () => window.setTimeout(handleResize, 500); | ||
|
|
||
| useEffect(() => { | ||
| // Call handleResize on mount to set initial dimensions | ||
| handleResize(); | ||
| window.addEventListener('resize', resizeDelay); | ||
| return () => window.removeEventListener('resize', resizeDelay); | ||
| }, []); | ||
|
Comment on lines
70
to
75
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,43 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| // Copyright contributors to the kepler.gl project | ||
|
|
||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import React, {useEffect, useRef} from 'react'; | ||
| import {createRoot} from 'react-dom/client'; | ||
| import {Provider} from 'react-redux'; | ||
| import App from './app'; | ||
| import Window from 'global/window'; | ||
| import {addDataConfigToKeplerGl} from '../kepler.gl'; | ||
|
|
||
| function renderRoot({id, store, ele}) { | ||
| const Root = () => ( | ||
| // Separate component to handle data loading after mount | ||
| function DataLoader({store, onRenderComplete}) { | ||
| const hasLoadedData = useRef(false); | ||
|
|
||
| useEffect(() => { | ||
| // This runs AFTER component tree is mounted and Provider is fully subscribed | ||
| // Load data from Window.__keplerglDataConfig (HTML export mode) | ||
| if (!hasLoadedData.current && Window.__keplerglDataConfig) { | ||
| hasLoadedData.current = true; | ||
| const {data, config, options} = Window.__keplerglDataConfig; | ||
| addDataConfigToKeplerGl({data, config, options, store}); | ||
| } | ||
| // Signal render complete for callback-based loading (Jupyter widget mode) | ||
| if (onRenderComplete) { | ||
| onRenderComplete(); | ||
| } | ||
| }, [store, onRenderComplete]); | ||
|
Comment on lines
+18
to
+30
|
||
|
|
||
| return null; | ||
| } | ||
|
|
||
| function renderRoot({id, store, ele, onRenderComplete}) { | ||
| // Use React 18 createRoot API | ||
| const root = createRoot(ele); | ||
| root.render( | ||
| <Provider store={store}> | ||
| <DataLoader store={store} onRenderComplete={onRenderComplete} /> | ||
| <App /> | ||
| </Provider> | ||
| ); | ||
|
yharby marked this conversation as resolved.
|
||
|
|
||
| ReactDOM.render(<Root />, ele); | ||
| } | ||
|
|
||
| export default renderRoot; | ||
Uh oh!
There was an error while loading. Please reload this page.