Back to Browse

React Hooks - useState initialize expensive derived state

820 views
Oct 28, 2018
1:33

See correction below! How to initialize state with React hooks when calculating the initial state is an expensive operation, by passing a callback function for the state initializer Correction: When I say the initial render is faster what I should say is that the initial render after starting the profiler (and all subsequent renders) are faster. That is because the state initializer function is run once only, on the initial render, which occurred before I started profiling. Sorry if that was unclear.

Download

1 formats

Video Formats

360pmp44.0 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

React Hooks - useState initialize expensive derived state | NatokHD