forked from atlassian/react-sweet-state
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to React 18 and useSyncExternalStore (atlassian#162)
- Loading branch information
1 parent
9ce56ee
commit dba9676
Showing
27 changed files
with
18,173 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,49 @@ | ||
// @flow | ||
import React, { Component } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { defaults } from 'react-sweet-state'; | ||
import React, { Component, StrictMode } from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
|
||
import { TreeRpc } from './views/tree-rpc'; | ||
import { TreeHooks } from './views/tree-hooks'; | ||
import { Tree } from './views/tree'; | ||
|
||
/** | ||
* Enable Batch updates | ||
*/ | ||
defaults.batchUpdates = true; | ||
|
||
const [TYPE = '', DEPTH = '2'] = window.location.hash | ||
.replace('#', '') | ||
.split('|'); | ||
const [DEPTH = '2'] = window.location.hash.replace('#', '').split('|'); | ||
|
||
/** | ||
* Main App | ||
*/ | ||
class App extends Component<{}, any> { | ||
state = { | ||
type: TYPE, | ||
depth: Number(DEPTH), | ||
}; | ||
|
||
onChangeType = (ev) => { | ||
const { depth } = this.state; | ||
const type = ev.target.value; | ||
this.setState({ type }); | ||
window.location.hash = type + '|' + depth; | ||
}; | ||
|
||
onChangeDepth = (ev) => { | ||
const { type } = this.state; | ||
const depth = Number(ev.target.value); | ||
this.setState({ depth }); | ||
window.location.hash = type + '|' + depth; | ||
window.location.hash = depth; | ||
}; | ||
|
||
render() { | ||
const { type, depth } = this.state; | ||
const { depth } = this.state; | ||
return ( | ||
<div> | ||
<h1>Performance ({type})</h1> | ||
Type:{' '} | ||
<select onChange={this.onChangeType} value={type}> | ||
{['', 'rpc', 'hooks'].map((v) => ( | ||
<option key={v} value={v}> | ||
{v} | ||
</option> | ||
))} | ||
</select> | ||
<h1>Performance</h1> | ||
Depth:{' '} | ||
<select onChange={this.onChangeDepth} value={depth}> | ||
{['2', '5', '10'].map((v) => ( | ||
{['0', '2', '5', '10'].map((v) => ( | ||
<option key={v} value={v}> | ||
{v} | ||
</option> | ||
))} | ||
</select> | ||
<main> | ||
{type === 'rpc' && <TreeRpc n={depth} />} | ||
{type === 'hooks' && <TreeHooks n={depth} />} | ||
<Tree n={depth} /> | ||
</main> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
const root = ReactDOM.createRoot(document.getElementById('root')); | ||
root.render( | ||
<StrictMode> | ||
<App /> | ||
</StrictMode> | ||
); |
Oops, something went wrong.