-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(UI): build base components #1
Conversation
function ClientOnly({ children, fallback = null }: ClientOnlyProps) { | ||
const [hydrated, setHydrated] = useState(() => !hydrating); | ||
|
||
useEffect(function hydrate() { | ||
hydrating = false; | ||
setHydrated(true); | ||
}, []); | ||
|
||
return hydrated ? <>{children()}</> : <>{fallback}</>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remix by default will try to do an initial server rendering of all the components and deliver them to the browser, this might be a problem for some components that would depend on any browser API, which would break on the server.
This component is a HOC that will wrap these components and skip their server rendering, allowing the client to do the whole job. I haven't used it yet, but it might be useful for later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
This PR builds some base components that would be used for the upcoming UI. It includes: