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

rem() is not available in React Server Component #5119

Closed
SukkaW opened this issue Oct 25, 2023 · 3 comments
Closed

rem() is not available in React Server Component #5119

SukkaW opened this issue Oct 25, 2023 · 3 comments
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@SukkaW
Copy link

SukkaW commented Oct 25, 2023

What package has an issue

@mantine/core

Describe the bug

The rem() function is not available in the React Server Component. When importing rem from a React Server Component, the following error appears:

Error: Attempted to call rem() from the server but rem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.

What version of @mantine/* packages do you have in package.json? (Note that all @mantine/* packages must have the same version in order to work correctly)

7.1.5

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

None

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

It appears that the published rem.mjs and rem.js contain the 'use client' directive, which is completely unnecessary.

@SukkaW SukkaW changed the title rem() is not available React Server Component rem() is not available in React Server Component Oct 26, 2023
@conduongtong
Copy link

I got an issue with rem when using in Server Component in 7.1.7:

Error: (0 , _mantine_core__WEBPACK_IMPORTED_MODULE_5__.rem) is not a function```

@SukkaW
Copy link
Author

SukkaW commented Nov 5, 2023

Current workaround: use https://foxact.skk.moe/rem

- import { rem } from '@mantine/core' 
+ import { mantine_rem as rem } from 'foxact/rem';

rtivital added a commit that referenced this issue Nov 7, 2023
@rtivital rtivital added the Fixed patch Completed issues that will be published with next patch (1.0.X) label Nov 7, 2023
@rtivital
Copy link
Member

rtivital commented Nov 7, 2023

Fixed in 7.2.1.

@rtivital rtivital closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants