How to use Redux and ReactJS from JSDelivr CDN with HTML and vanilla JavaScript

Srecko Kostic
Mar 1, 2023

--

A complete runnable and copy paste-able example on how to use HTML, ReactJS and Redux with vanilla javascript.

code that creates redux store

Explanation

  1. Load the libraries from CDN — ReactJS, ReactDOM and Redux
  2. Make a script tag below that should have available ReactJS, ReactDOM, and Redux objects because libraries are loaded
  3. Create redux store by following documentation on how to do it
  4. Create two reduces by following documentation on how to do it
  5. Store the initial store state inside react component.
  6. 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.
  7. Create buttons to change the state.

Here is a link to the gist

full copy paste and runnable example

--

--

Srecko Kostic

I create content from my perspective on topics I learn. Some information may be incorrect, but I hope some find my content useful.