DEV Community


react context API empty in childs after build with rollup

iminosgfx profile image iMinosGFX ・1 min read

I have created a Server side table component which is quite complex and to manage the interactions with the filters I have used a context provider which encompasses the whole component. During the development on a test project I didn't have any problem, only after building it to make a library with rollup I had some problems, especially this one.

When importing the library in my main project, nothing works because the state of the context retrieved by the children is always empty (useContext).
Searching on internet I have the impression that it is a problem of context conflicts, but trying several solutions nothing works...

Here is the state of the context in the react dev tools :

and here is the state retrieved by the children:

You can find repo of the component here (for the config and main code), the main component being ServerSideTable :

Could you tell me after building the component and using it on another project, the children don't get the data?

Thanks a lot !

Discussion (0)

Editor guide