Upgrade to Pro — share decks privately, control downloads, hide ads and more …

React Fiber - ReactJS Dublin Meetup

React Fiber - ReactJS Dublin Meetup

An overview of React Fiber, 5 min lightning talk for the ReactJS Dublin meetup of February 22nd 2017, kindly hosted by Hubspot.

Mostly based on the hangout hosted by Kent C. Dodds with Andrew Clark and Dan Abramov, as well as Andrew's Fiber architecture overview.

https://www.meetup.com/ReactJS-Dublin/events/236985643/
https://claudiopro.github.io/react-fiber-lightning-talk/
https://claudiopro.github.io/react-fiber-vs-stack-demo/

Claudio Procida

February 22, 2017
Tweet

More Decks by Claudio Procida

Other Decks in Programming

Transcript

  1. Hi!

  2. Stack: Issues Heavyweight context Can't be split in chunks Java-like

    OO architecture See for insight Sebastian Markbåge's notes
  3. Fiber: Goals Pause and resume work Assign priority to different

    types of work Reuse previously completed work Abort work that is no longer needed
  4. Fiber: Pros Does not drop frames Splits work across frames

    Commits when work is complete Can de-prioritize offscreen work
  5. Fiber: Cons Harder to debug Better tooling needed Dif cult

    to reason about Non instantaneous updates
  6. Fiber: Caveats In Fiber, setState() calls will be batched more

    frequently. This code may not work as expected: Use the callback form instead: // Wrong this.setState({ counter: this.state.counter + this.props.increment }); // Correct this.setState((prevState, props) => ({ counter: prevState.counter + props.increment }));
  7. Fiber: Extras Error Boundaries Multiple components in render() Portals for

    dialogs Better SSR performance without client-side logic
  8. Fiber: When? Already in master HEAD (go check it out!)

    Expected enabled by default in React 16 http://is berreadyyet.com