How to use Redux and ReactJS from JSDelivr CDN with HTML and vanilla JavaScript
Mar 1, 2023
A complete runnable and copy paste-able example on how to use HTML, ReactJS and Redux with vanilla javascript.
Explanation
- Load the libraries from CDN — ReactJS, ReactDOM and Redux
- Make a script tag below that should have available ReactJS, ReactDOM, and Redux objects because libraries are loaded
- Create redux store by following documentation on how to do it
- Create two reduces by following documentation on how to do it
- Store the initial store state inside react component.
- Idea of the App component is: Use useEffect to create a listener only once when the component is created and clear up the listener before the component is removed. Every time state changes, update state in the component.
- Create buttons to change the state.