英文:
Use React-Redux in coding apps
问题
It seems like you are trying to use the configureStore()
function from Redux Toolkit in an Android coding app with React-Redux. However, you're encountering issues with the correct usage of this function. Here are some suggestions:
- Make sure you have imported Redux Toolkit correctly. It should be imported like this:
import { configureStore } from '@reduxjs/toolkit';
- Ensure you have Redux Toolkit installed in your project. You can install it using npm or yarn:
npm install @reduxjs/toolkit
# or
yarn add @reduxjs/toolkit
- Once you have imported
configureStore
, you can use it to create your store. Here's an example:
import { configureStore } from '@reduxjs/toolkit';
const store = configureStore({
// Configure your store options here, such as reducers and middleware
});
// Now you can use the 'store' in your application
Make sure to configure your store with the necessary options according to your app's requirements.
That should help you use configureStore()
correctly in your Android coding app with React-Redux.
英文:
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.
答案1
得分: 2
根据入门指南文档,似乎是在全局窗口对象上。
它还以预编译的UMD包的形式提供,定义了一个名为
window.RTK
的全局变量。UMD包可以直接作为<script>
标签使用。
看起来configureStore
可以这样访问:
window.RTK.configureStore
或者只是
RTK.configureStore
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论