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

Add react-meteor-state/use-meteor-state #333

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

CaptainN
Copy link
Collaborator

@CaptainN CaptainN commented May 12, 2021

This adds the react-meteor-state package! This package contains the useMeteorState hook, which provides a state manager like React's build in useState built on Meteor's Reload package. The result, state persists between page refreshes during development and hot-code-push!

The only downside is that you have to name each use with a globally unique name - so this is not a direct replacement for useState.

TODO:

  • tests
  • documentation (readme)

@CaptainN CaptainN mentioned this pull request May 12, 2021
Copy link
Collaborator

@StorytellerCZ StorytellerCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update dependencies. Will try to test this weekend to provide more feedback.

@filipenevola
Copy link
Collaborator

@CaptainN how can we help here?

@CaptainN
Copy link
Collaborator Author

CaptainN commented Dec 8, 2021

This just needs documentation and tests. (Or an executive decision to skip those)

@CaptainN
Copy link
Collaborator Author

CaptainN commented Mar 24, 2022

This useId hook has the potential to make this a full blown meteor flavored replacement for useState. I might even be inclined to provide one for useReducer as well. (Er maybe not? I think I jumped the gun. The ID it generates would not survive a reload.... nm)

@Grubba27
Copy link
Contributor

Grubba27 commented Sep 1, 2022

How would it be an example of the use of this?
I could probably try to help to test, but creating a good readme is an easy win.
Do you have an example of using this custom hook?

@CaptainN
Copy link
Collaborator Author

CaptainN commented Sep 1, 2022

It's almost the same as using useState except you need to name the object with a globally unique string. You would use this for something like form input - then when the page refreshes due to a meteor refresh, that data should be restored. That would work through both development refreshes and during hot-code pushes.

@StorytellerCZ
Copy link
Collaborator

Have been using this in production for over two years now without a problem. Let's get this finished please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants