-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Hi — really loving this library, thanks for your excellent work here.
I've noticed a behavior that I would appreciate some clarification on. On initial renders without any conditional logic, loading is set to false and data is undefined.
Subsequently, the doc's example usage, while obviously contrived, does not work in a way I would expect:
// components/Post.tsx
const Post = () => {
const { data, loading } = useStore($currentPost);
if (data) return <div>{data.content}</div>;
if (loading) return <>Loading...</>;
console.warn("💀 This is actually rendered! Not what I would expect.");
return <>Error!</>;
};You can see live examples of this log here.
This is easy enough to work around, as you can just create a function that tracks an initialization state that looks at if loading has ever been toggled from false to true. That said, I'd like to recommend updating the docs to make note of this behavior. Let me know what you think; happy to open a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels