Due my current work task i have a case - to call a modal created as a React-component from SharePoint Ribbon. In two words, SharePoint ribbon is a structure that contains buttons and js-functions binded for it. When you push the button, js function binded for it calls... hope you understand :). And i started to google: how to interact with react module from outer js, how to change react state from outer js, force re-render react component from pure js and so on... So, the main problem is: you cannot bind react-component function to ribbon button because it hides deep inside into webpack js bundle. Also, i need to change React Module state because i want rerender component when i click the button. So, i make the fiddle and looks like it works correctly - https://jsfiddle.net/o6ujb5g2/. It is not SharePoint ribbon, but almost the same. Idea is to attach function from react modal to global window object. This object exist from almost anywhere.
Steps:
I created a stub-function in pure js for window.func that i want to override from component (it is for safety, if some problems with component will happens due it's render)
In component i initialize a func with business logic, that changes component state
On componentDidMount i override global window.func to module.func
A step-by-step guide to setting up Storybook in your React.js project, including configuration tips, code examples, and best practices for building a component library.
A practical guide to setting up import path aliases in Create React App projects using CRACO or react-app-rewired, with step-by-step configuration examples.
Open for contract collaboration
I am available for contract-based collaboration. If you have an interesting project idea, schedule a call via Calendly.