Unable to use Customizer with multiple packages
Environment Information
- Package version(s): 7.69.3
- Browser and OS versions: chrome 80.0.3987.116
Describe the issue
I would like to apply a custom theme using the Customizer component to a set of fabric components which are contained in different symlinked libraries.
This feature works great if all the components are contained within the same package. However when I introduce a set of components from a custom library via symlink. The context is lost and the theme does not work.
Please provide a reproduction of the issue in a codepen:
I have created a simple example to illustrate my problem in a GitHub repo. I cannot reproduce it on CodePen due to the nature of the bug.
- Clone repository: https://github.com/jacksonv1lle/customizations-test
- cd into app1
- npm install
- npm link
- npm run build
- cd into app2
- npm install
- npm link app1
- npm run start
Actual behavior:
The app shows two PrimaryButton components. One is appearing with a custom red theme. And the other is appearing as default.
Although both components are children of the Customizer, only one component inherits the theme.
Expected behavior:
Both PrimaryButton components should have the red theme.
Priorities and help requested:
Are you willing to submit a PR to fix? No
Requested priority: Normal
Hi @jacksonv1lle, thanks for reaching out to us! As far as I know, it shouldn't be an issue for Customizer to work across packages but might be due to the different symlinks you're using. And you're also introducing non-Fabric components from a custom library right? Perhaps that's the cause also... CustomizerContext which is what lies beneath Customizer uses React.Context and it seems like React.Context doesn't support sharing context across multiple packages... it seems like there is discussion about how to do this in the wild https://medium.com/@nathanqueija/how-to-share-state-between-different-packages-using-react-context-api-40cc0ceda50d but I believe you'd have to implement this in your own custom provider
This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fabric React!