-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Next.js: Allow multiple component in imports #3481
Comments
You must have missed this pinned ticket: #3288 |
You need to run |
that error has nothing to do with the above. You are missing an import. I thin kyou need to take a step back and build a simple example. You are trying to |
Start simple with this PrimeReact starter for Next.JS: https://github.com/primefaces/primereact-examples/tree/main/nextjs-basic |
https://codesandbox.io/s/rough-firefly-84kwwi?file=/pages/index.js. here is an example, just made it... let me know pls what i'm missing. |
I re-opened your ticket and updated the description. Looks like this problem is specific to Next.JS as it works fine with Create React App. Your only solution right now is to use explicit components like.. import { Button} from "primereact/button"
import { InputText } from "primereact/inputtext" |
yes it seems like there's a bug. thanks anyway, pls update me when is fixed :D |
Hi @vitalijalbu, Please have a look at the link below; |
@ulasturann pls see here, they told me it was an issue with the library, i want multiple imports {button, input, ...etc} |
Hi again @vitalijalbu,
|
yes but it's no a good idea, instead of having 1 row of import components, we'll have 10! |
@vitalijalbu that is purely syntax but by doing it the "tree shaking" way you actually are making a smaller more efficient deployment. Your way it has to bring in the entire primereact.js file instead of just the components you are using. And your reason is because you want imports on one line??? That doesn't seem like a good tradeoff for performance. |
Describe the bug
When using Next.js and trying to import
import { Button, InputText } from "primereact";
it fails with.Works fine if you use tree shaking imports however like:
Reproducer
https://codesandbox.io/s/youthful-carlos-gckc2q?file=/pages/index.js
PrimeReact version
8.6.1
React version
18.x
Language
ALL
Build / Runtime
Next.js 12.3.1
The text was updated successfully, but these errors were encountered: