使用React-Redux编写应用程序

huangapple go评论76阅读模式
英文:

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:

  1. Make sure you have imported Redux Toolkit correctly. It should be imported like this:
import { configureStore } from '@reduxjs/toolkit';
  1. 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
  1. 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 &lt;script&gt;
> tag
directly.

It looks like configureStore could be accessed as

window.RTK.configureStore

or maybe just

RTK.configureStore

huangapple
  • 本文由 发表于 2023年5月11日 14:27:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76224707.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定