primereact
primereact copied to clipboard
Local Development: primereact context is undefined
I installed primereact locally and linked it to my Next.js app as described here https://github.com/primefaces/primereact/blob/master/DEVELOPMENT.md everythig works well except context, which is undefined even if I wrap my components with PrimeReactProvider and set some value to it.
step to reproduce:
- create next-app
- clone primereact master
- follow the development guide to link primereact to next-app
- in next-app app/layout wrap children with PrimeReactProvider and set value some value like {unstyled: true}
- in next-app app/page create a simple prime react component like a button
- run the script dev: "next dev" without --turbopack
expected result: a button doesn't have the primereact classes like 'p-button' because unstyled prop is set to true in a contex actual result: context is undefined so we can see primereact classes
This issue is available for anyone to work on. Make sure to reference this issue in your pull request. :sparkles: Thank you for your contribution! :sparkles:
I also experienced this and while I don't have a solution for link mode i can share what I found and what I do instead. NPM Link forces all internal dependencies to be included in every single file that uses them. We cant remove that because it causes resolution errors in link mode. I use yalc (https://github.com/wclr/yalc) instead.
Steps: 1: (only once)
npm run build:lib
cd dist
yalc publish
2: In the project you want to use local Primereact:
yalc add primereact
3: After your changes
npm run build:lib
cd dist
yalc push
4: To reset
yalc remove primereact
npm install primereact
This works without issues.
@gnawjaren any chance you could update https://github.com/primefaces/primereact/blob/master/DEVELOPMENT.md guide?