2

How can I load the React-Redux (React binding for Redux) JavaScript library onto a web page with a simple script tag?

I have seen examples of loading React-Redux as an NPM module from node_modules, but in my case that is not an option.

I'm after something like this:

<!-- load React-Redux with simple script tag -->
<script src="....."></script>

<script>
  // Cannot use npm modules from node_modules, so cannot use
  // import { Provider } from "react-redux";

  // Assign Provider and connect variable if needed from 
  // some symbol defined in the .js file that was loaded 
  // by the script tag
  var Provider = ....;
  var connect = ....;

  // Load my own hypothetical ES6 modules (not relevant to this question)
  import store from "./store";
  import App from "./App";

  const rootElement = document.getElementById("root");
  ReactDOM.render(
    <Provider store={store}>
      <App />
    </Provider>,
    rootElement
  );
</script>
1
  • Would love to learn in what case you are in where this is not an option. I have yet to run into that problem. Commented Oct 31, 2018 at 21:22

1 Answer 1

1

All you need is mentioned right here.

<script src="https://unpkg.com/[email protected]/dist/react-redux.min.js"></script>

Then you can basically use window.ReactRedux.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.