primereact icon indicating copy to clipboard operation
primereact copied to clipboard

Local Development: primereact context is undefined

Open lumo10 opened this issue 5 months ago • 1 comments

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.

Image

step to reproduce:

  1. create next-app
  2. clone primereact master
  3. follow the development guide to link primereact to next-app
  4. in next-app app/layout wrap children with PrimeReactProvider and set value some value like {unstyled: true}
  5. in next-app app/page create a simple prime react component like a button
  6. 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

lumo10 avatar Jun 05 '25 07:06 lumo10

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:

github-actions[bot] avatar Jun 05 '25 11:06 github-actions[bot]

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 avatar Jul 05 '25 19:07 gnawjaren

@gnawjaren any chance you could update https://github.com/primefaces/primereact/blob/master/DEVELOPMENT.md guide?

melloware avatar Jul 06 '25 11:07 melloware