javascript - React Native + Redux,使用 Express 后端设置
问题描述
我有一个将 redux 和 Axios 链接到 Express 后端的 ReactJS 网站。现在我必须从这个站点构建一个 React Native 应用程序,但我想使用相同的后端和数据库。网上发现React Native也可以使用Redux + Axios的功能!但是我可以使用我的 ReactJS 站点中的相同代码在我的应用程序上实现 Redux 功能吗?我发现 action/reducer 功能大部分都相同,但我可以使用像下面这样的 Redux 商店(我的 ReactJS 商店)在我的应用程序中创建商店吗?
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers';
const initialState = {};
const middleware = [thunk];
const store = createStore( rootReducer, initialState, compose(
applyMiddleware(...middleware),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
));
export default store;
我必须遵循一些特定的规则,或者我需要在我的应用程序中实施一些设置以使其正常工作?
解决方案
推荐阅读
- r - 如何比较 2 个数据帧并选择其中一个数据帧的某些行,这些行在另一个 df 的某些列中具有相同的值
- c# - 如何通过 In EF CORE 执行与组的联接操作
- python - python中的镜像
- relayjs - 禁用relayjs垃圾收集
- python - 无法在类中腌制 sqlAlchemy 引擎
- javascript - IOS Safari window.alert,window.confirm 在 onpopstate 触发后不起作用
- vue.js - 禁用 Vue Bootstrap 表头重命名
- python - Pytesseract 阅读文本时出现随机错误
- java - MongoDB 静态连接错误:令牌上的语法错误,应改为 AnnotationName
- c# - 调用方法在 Windows 打开对话框上不起作用