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

feat(UI): build base components #1

Merged
merged 11 commits into from
Nov 21, 2022
Merged

feat(UI): build base components #1

merged 11 commits into from
Nov 21, 2022

Conversation

mapra99
Copy link
Owner

@mapra99 mapra99 commented Nov 19, 2022

This PR builds some base components that would be used for the upcoming UI. It includes:

  • Text
  • Button
  • TextInput
  • RadioInput
  • QuantityInput
    image

Comment on lines +6 to +15
function ClientOnly({ children, fallback = null }: ClientOnlyProps) {
const [hydrated, setHydrated] = useState(() => !hydrating);

useEffect(function hydrate() {
hydrating = false;
setHydrated(true);
}, []);

return hydrated ? <>{children()}</> : <>{fallback}</>;
}
Copy link
Owner Author

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

Copy link
Collaborator

@ImMPrada ImMPrada left a comment

Choose a reason for hiding this comment

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

🚀

@mapra99 mapra99 merged commit f41dddd into main Nov 21, 2022
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.

None yet

2 participants