React State Round Up

Published: Aug. 5, 2020, 1 p.m.

b'

In this episode of Syntax, Scott and Wes talk about React State libraries, should you use them, pros, cons, and more!

Sanity - Sponsor

Sanity.io\\xa0is a real-time headless CMS with a fully customizable Content Studio built in React. Get a Sanity powered site up and running in minutes at\\xa0sanity.io/create. Get an awesome supercharged free developer plan on\\xa0sanity.io/syntax.

Sentry - Sponsor

If you want to know what\\u2019s happening with your errors, track them with\\xa0Sentry. Sentry is open-source error tracking that helps developers monitor and fix crashes in real time. Cut your time on error resolution from five hours to five minutes. It works with any language and integrates with dozens of other services. Syntax listeners can get two months for free by visiting\\xa0Sentry.io\\xa0and using the coupon code \\u201ctastytreat\\u201d.

Show Notes

01:24 -\\xa0Context

  • Have we used?
    • Scott: Yes
    • Wes: Yes
  • Pros
    • Built into React
    • As simple or complex as you want
  • Cons
    • Takes effort to optimize
    • Takes effort to plan and organize aka can get out of hand quickly

08:49 -\\xa0Redux

  • Have we used?
    • Scott: Yes
    • Wes: Yes
  • Pros
    • Huge user base
    • Legacy of growth and improvements
    • Modern API
    • Even though it\\u2019s hard to learn, it has a clear \\u201chow to build with it\\u201d path
    • Dev tools
  • Cons
    • Complex
    • Thing that calls a thing that calls a thing that calls a thing
    • Confusion around what additional packages are needed, e.g. ducks, saga, whatever

17:08 -\\xa0XState

  • Have we used?
    • Scott: Yes
    • Wes: No
  • Pros
  • Cons
    • Knowledge overhead - having to understand state machines
    • Complex syntax

23:26 -\\xa0Zustand

  • Have we used?
    • Scott: Yes
    • Wes: No
  • Pros
    • Fast, scalable, easy to use
    • Simpler
    • No context providers
  • Cons
    • Smaller community 2.6k stars on Github
    • Can inform components transiently (without causing render)

27:04 -\\xa0Apollo Client

  • Have we used?
    • Scott: Yes
    • Wes: Yes
  • Pros
    • Fits in well with your GraphQL API
    • Dev tools
  • Cons
    • Complex, large syntax for simple operations
    • Dev tools
    • SSR story is really complex. It\\u2019s hard because they aren\\u2019t also the framework.

31:35 -\\xa0RXJS

  • Have we used?
    • Scott: No
    • Wes: No
  • Observable based

33:02 -\\xa0React Query

  • Have we used?
    • Scott: No
    • Wes:
  • Pros
    • Fast growing community
    • Awesome dev tools
  • Cons
    • Not sure if this can be used for application state or just data

35:37 -\\xa0Recoil

  • Have we used?
    • Scott: Yes
    • Wes: No
  • Pros
    • Very good for complex, splintered state needs
  • Cons
    • Overly complex for most use cases

38:34 -\\xa0MobX

  • Have we used?
    • Scott: No
    • Wes: No
  • Pros
    • Big community
    • Not just React
    • Powerful
    • Observable capabilities
  • Cons
    • Uses decorators, but doesn\\u2019t have to?

43:15 -\\xa0Easy Peasy

  • Have we used?
    • Scott: No
    • Wes: No
  • Pros
    • Simple API (easy peasy)
    • Redux dev tools supported

45:06 -\\xa0Meteor ReactiveDict\\xa0/\\xa0ReactiveVar

  • Have we used?
    • Scott: Yes
    • Wes: No
  • Pros
    • Very simple
    • Get, set
    • Is Reactive
  • Cons
    • Lock-in to Meteor

46:19 - Final Thoughts On State

  • Wes: Go for simpler solutions
  • Scott: I think application state should be separate from application data, but maybe that\\u2019s because there isn\\u2019t a solution that does both how I want

Links

\\xd7\\xd7\\xd7 SIIIIICK \\xd7\\xd7\\xd7 PIIIICKS \\xd7\\xd7\\xd7

Shameless Plugs

Tweet us your tasty treats!

'