headstartwp icon indicating copy to clipboard operation
headstartwp copied to clipboard

Provide a simple (opt-in) state management solution

Open nicholasio opened this issue 3 years ago • 1 comments

Is your enhancement related to a problem? Please describe.

The idea here is to provide an optional, built into the framework state management solution that could be used by project teams when they need to share data between components.

Describe the solution you'd like

I'd love to do a bit of an initial discovery here to come up with simple solutions. Here are my initial thoughts:

  • Redux is probably overkill
  • Context API might work well for simple use cases but might not scale very well.
  • Note that we don't want to store API data in the state, all of the data is to be handled by Next.js/useSWR. What I'm thinking here is UI state, things like Cart (for e-commerce websites), user auth state etc.

Let's do a bit of exploration and come up with a few suggestions.

I was thinking of the framework making it super easy to dispatch/action and access the shared state. Note that we should strive to only re-render components if the state of the components needs changes.

As an example, here's how Frontity handles this: https://tutorial.frontity.org/part3-displaying-posts/understanding-the-frontity-state

Designs

Describe alternatives you've considered

Additional context

nicholasio avatar Oct 27 '21 00:10 nicholasio