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

refactor: useStore! instead of checking for null #546

Merged
merged 1 commit into from
Sep 15, 2023

Conversation

lihebi
Copy link
Collaborator

@lihebi lihebi commented Sep 15, 2023

We don't need to report the error. The error will be reported by zustand. Just keep in mind that the store is only valid inside a provided by RepoContext.Provider:

export function Repo({ yjsWsUrl }) {
let { id } = useParams();
const store = useRef(createRepoStore()).current;
const setRepo = useStore(store, (state) => state.setRepo);
// console.log("load store", useRef(createRepoStore()));
useEffect(() => {
setRepo(id!);
}, []);
return (
<RepoContext.Provider value={store}>

@lihebi lihebi merged commit 527cf68 into codepod-io:main Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant