javascriptreactjsreact-reduxredux-toolkitumd

Use React-Redux in coding apps


Q How to use configureStore on an offline coding app?

I am trying to use react-redux in an android coding app. And I included the umd code like this:

<script type='text/javascript' src='js/lib/babel.min.js'></script>
<script type='text/javascript' src='js/lib/react.development.js'></script>
<script type='text/javascript' src='js/lib/react-dom.development.js'></script>
<script type='text/javascript' src='js/lib/redux.js'></script>
<script type='text/javascript' src='js/lib/react-redux.js'></script>
<script type='text/javascript' src='js/lib/redux-toolkit.umd.js'></script>
<script type='text/babel' src='js/app/app.js'></script>

I can use <Provider> and createStore() and combineReducers() by prefixing them with Redux like Redux.createStore(). The problem is I cannot use configureStore().

I tried configureStore

Redux.configureStore

ReduxToolkit.configureStore

and more, either configureStore() is not defined or the module doesn't exist.


Solution

  • Based on the Getting Started documentation it appears to be on the global window object.

    It is also available as a precompiled UMD package that defines a window.RTK global variable. The UMD package can be used as a <script> tag directly.

    It looks like configureStore could be accessed as

    window.RTK.configureStore
    

    or maybe just

    RTK.configureStore