This file contains hidden or 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
| const SlowComponent = React.memo(({ text, onClick }) => { | |
| const arr = [] | |
| for (var i = 1000000 - 1; i >= 0; i--) { | |
| arr.push(i) | |
| } | |
| return ( | |
| <div> | |
| <div>I'm slow {text}</div> | |
| <button onClick={onClick}/> | |
| </div> |
This file contains hidden or 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
| adb reverse tcp:8097 tcp:8097 |
This file contains hidden or 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
| <script src="http://localhost:8097"></script> |
This file contains hidden or 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
| npm install -g react-devtools | |
| react-devtools |
This file contains hidden or 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
| import { | |
| unstable_trace as trace, | |
| unstable_wrap as wrap, | |
| } from 'scheduler/tracing' | |
| const useData = () => { | |
| const [loading, setLoading] = useState(false) | |
| const [data, setData] = useState(null) | |
| const fetch = () => { |
This file contains hidden or 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
| import { | |
| unstable_trace as trace, | |
| unstable_wrap as wrap, | |
| } from 'scheduler/tracing' | |
| <button | |
| onClick={() => | |
| trace('Fetch data', performance.now(), () => { | |
| setLoading(true) | |
| fetchData() |
This file contains hidden or 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
| import { | |
| unstable_trace as trace, | |
| } from 'scheduler/tracing' | |
| <input | |
| type="text" | |
| value={name} | |
| onChange={e => { | |
| trace('Enter user name', performance.now(), () => | |
| onChange(e.target.value) |
This file contains hidden or 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
| const ROUNDS = 100_000 | |
| const Benchmark = () => { | |
| const [took, setTook] = useState() | |
| const [round, setRound] = useState(1) | |
| const start = useRef(performance.now()) | |
| useEffect(() => { | |
| if (round < ROUNDS) { | |
| setRound(round + 1) | |
| } else { |
This file contains hidden or 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
| # Using Yarn | |
| yarn build --profile | |
| # Using NPM | |
| npm run build -- --profile |
This file contains hidden or 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
| module.exports = { | |
| //... | |
| resolve: { | |
| alias: { | |
| 'react-dom$': 'react-dom/profiling', | |
| 'scheduler/tracing': 'scheduler/tracing-profiling', | |
| } | |
| } | |
| }; |