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

Consider removing useStore #44

Open
cefn opened this issue Nov 6, 2023 · 0 comments
Open

Consider removing useStore #44

cefn opened this issue Nov 6, 2023 · 0 comments
Labels
store-react Related to @watchable/store-react

Comments

@cefn
Copy link
Owner

cefn commented Nov 6, 2023

The implementation of useStore is just...

export function useStore<T extends RootState>(initialState: Immutable<T>) {
  const [store] = useState(() => {
    return createStore(initialState);
  });
  return store;
}

Perhaps this is so minimal (and such an unnecessary black box) that it should just be removed. Ideally developers would know what they are doing with store identity. Withdrawing this hook would require them to directly consider the approach they are taking. For many applications, a store created outside React altogether is a good option, for example, and eliminates any unexpected behaviours associated with store identity or initial state.

@cefn cefn added the store-react Related to @watchable/store-react label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
store-react Related to @watchable/store-react
Projects
None yet
Development

No branches or pull requests

1 participant