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

[Bug]: Icons in next.js 13 #693

Open
anthonycook opened this issue Sep 18, 2023 · 4 comments · May be fixed by #758
Open

[Bug]: Icons in next.js 13 #693

anthonycook opened this issue Sep 18, 2023 · 4 comments · May be fixed by #758
Labels
Type: Bug Confirmed bug, something is not working as intended

Comments

@anthonycook
Copy link

Tremor Version

3.7.7

Link to minimal reproduction

https://codesandbox.io/p/sandbox/priceless-euler-7wn4cx

Steps to reproduce

I'm using next.js 13 with the app dir, I get this error when trying to pass the icon prop to any Tremor components that accept them, they are server side components (see repo link)

Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server"

What is expected?

I'd expect the icon to be able to be passed in server components

What is actually happening?

Not sure, it mentions specifying "use server", tried setting this in my components but it didn't work.

What browsers are you seeing the problem on?

No response

Any additional comments?

No response

@anthonycook anthonycook changed the title [Bug]: [Bug]: Icons in next.js 13 Sep 18, 2023
@severinlandolt
Copy link
Member

severinlandolt commented Sep 18, 2023

Hey there, by default Next.js uses server components. You can solve this by adding "use client";

This is not a Tremor problem per se, it's a paradigm shift introduced with Next 13.

+ "use client";
import { SearchIcon } from "@heroicons/react/solid";
import { TextInput } from "@tremor/react";

export default function Example() {
  return (
    <div>
      <TextInput icon={SearchIcon} placeholder="Search customers..." />
    </div>
  );
}

@anthonycook
Copy link
Author

anthonycook commented Sep 19, 2023

Hey @severinlandolt, that’s the issue. I want to use SSR for data fetching. Also adding useClient doesn’t work. I think it expects the Tremor component to specify useClient

@imprakharshukla
Copy link

imprakharshukla commented Sep 23, 2023

Hey! Did you fix this? Facing the same issue but I really do not want to give up the data fetching and make my component a "client-component".

This only happens if I pass a function to the valueFormatter of a chart.

@severinlandolt severinlandolt added Status: Help Wanted We need help with this issue Type: Bug Confirmed bug, something is not working as intended labels Sep 23, 2023
@zackkrida
Copy link

@anthonycook you might want to try this approach:

#154 (comment)

@motinados motinados linked a pull request Oct 14, 2023 that will close this issue
14 tasks
@severinlandolt severinlandolt removed the Status: Help Wanted We need help with this issue label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Confirmed bug, something is not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants