3 comments

[ 3.0 ms ] story [ 7.8 ms ] thread
A global initializeLaunch is a deal breaker.

Services should be passed a provider (similar to Redux). Having state stored globally can cause many issues:

- Testing is harder, as the state can be shared

- Having sub-stores is impossible

- Having parallel stores is impossible

Thanks for the feedback! As noted in my blog post, these types of tradeoffs were consciously made to simplify other aspects React state management. If, for example, sub-stores and/or parallel stores are important, Launch.IO might not be a good choice.
I don't see this as a large tradeoff. Taking from your example and modifying to follow good practices:

    const launch = initializeLaunch(/* ... */);
    
    const App = () => {
      // ...
    
      return (
        <LaunchProvider launch={launch}>
          <div>...</div>
        </LaunchProvider>
      );
    };