Created
June 22, 2021 10:53
-
-
Save marekpiechut/e749b71401dd1bc09c547f90fe8a2424 to your computer and use it in GitHub Desktop.
React-profiler
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 { useState } from 'react' | |
| const SlowComponent = ({ noSlowdown }) => { | |
| const arr = [] | |
| if (!noSlowdown) { | |
| for (var i = 1000000 - 1; i >= 0; i--) { | |
| arr.push(i) | |
| } | |
| } | |
| return <div>I'm slooooooow</div> | |
| } | |
| const FastComponent = () => { | |
| return <div>I'm fassssst....</div> | |
| } | |
| function App() { | |
| const [dummy, setDummy] = useState() | |
| return ( | |
| <div className="App"> | |
| <SlowComponent noSlowdown={dummy % 2} /> | |
| <FastComponent /> | |
| <button onClick={() => setDummy(Date.now())}>Render!</button> | |
| </div> | |
| ) | |
| } | |
| export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment