-
Notifications
You must be signed in to change notification settings - Fork 39
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
Client side only import executing on server when using SSR #189
Comments
"client-side" magic comment is suppressing However that would not block those modules/components from being used - you still can try to render them, and they will be rendered. const NoSSR = ({children}) => {
const [locked, setLocked] = useState(true);
useEffect(() => setLocked(false), []); // unlock on the client-side
return locked ? null : children;
} Check #47 for other solutions.
|
I'm trying out react-imported-component in a demo app before using it in a production app, and hit the following block.
I have an
About
component that I'm importing as follows:My understanding is that this would cause the
About
component to only be imported on the client side and thus never executed on the server side. However I have aconsole.log
statement in the About component that prints out on the server side.My
imported.js
file looks like this:I find the following confusing. In the
imported.js
comment number 1), it says if I use the magic comment/* client-side */
it would disappear from the file, however as you can see it doesn't.On the other hand if I understood correctly, in
__tests__/utils.spec.ts
line 21 the test checks that a client-side import should be mapped to the value at line 30.Can you please advise as to which behaviour from the above is expected, and how to get client-side only imports to work? Thank you
The text was updated successfully, but these errors were encountered: