272

August 5th, 2020 ×

React State Round Up

or

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 is 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 sanity.io/create. Get an awesome supercharged free developer plan on sanity.io/syntax.

Sentry - Sponsor

If you want to know what's happening with your errors, track them with Sentry. 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 Sentry.io and using the coupon code "tastytreat".

Show Notes

01:24 - Context

  • 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 - Redux

  • Have we used?
    • Scott: Yes
    • Wes: Yes
  • Pros
    • Huge user base
    • Legacy of growth and improvements
    • Modern API
    • Even though it's hard to learn, it has a clear "how to build with it" 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 - XState

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

23:26 - Zustand

  • 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 - Apollo 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's hard because they aren't also the framework.

31:35 - RXJS

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

33:02 - React 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 - Recoil

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

38:34 - MobX

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

43:15 - Easy Peasy

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

45:06 - Meteor ReactiveDict / ReactiveVar

  • 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's because there isn't a solution that does both how I want

××× SIIIIICK ××× PIIIICKS ×××

Shameless Plugs

Tweet us your tasty treats!

Share

Play / pause the audio
Minimize / expand the player
Mute / unmute the audio
Seek backward 30 seconds
Seek forward 30 seconds
Increase playback rate
Decrease playback rate
Show / hide this window