Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React State Management Design #17

Open
7 tasks
ddfridley opened this issue Jul 9, 2021 · 1 comment
Open
7 tasks

React State Management Design #17

ddfridley opened this issue Jul 9, 2021 · 1 comment
Labels
Challenging Will be hard to figure out React

Comments

@ddfridley
Copy link
Contributor

Unpoll needs a state manager. Redux is not acceptable - it's a long discussion if interested - but here are the requirements for the state manager design

  • Ability to use the browser's forward/back buttons to move through state. This likely means that history.pushState and .popState are used
  • Ability to refresh the page, or go back to the current URL, and get to the current position/state - likely this means that state info is encoded in the URL and the URL is updated with each state change. Again, pushState and popState are likely
  • Components with state are reused in a hierarchy or recursively - so the key to a component instance's state needs to be relative to it's place in the hierarchy not absolute. This may imply that some prop does need to be passed from parent to child, but open to ideas.
  • URL/Routes to pages/Components are programmatic not constant. Look at the location.url to determine the path, or compute it.
  • Components will render on the server side first, then be rehydrated and continue on the browser side. Much data is fetched on the server side, and then passed to the browser on the initial load.
  • Data is obtained through API calls - likely it should be separate from state, but sometimes data can be changed asynchronously by the server (using socket.io connections not REST)
  • Related code should be in the same place, ideally the same file, or the same directory. Having to separate code for a single function or feature, into different directories should be avoided. (no Redux) Think of each new product features as a module, and try to keep all the pieces of that module together in one place.
@ddfridley ddfridley added React Challenging Will be hard to figure out labels Jul 9, 2021
@ddfridley
Copy link
Contributor Author

I've create useMethods as a start for this: https://github.com/EnCiv/unpoll/blob/main/app/lib/use-methods.js but there is still a long way to go - and I'm open to common APIs if we can find something that fits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Challenging Will be hard to figure out React
Projects
None yet
Development

No branches or pull requests

1 participant