gpt4 book ai didi

javascript - createProvider 不是从react-redux导出的?

转载 作者:行者123 更新时间:2023-12-03 13:13:40 25 4
gpt4 key购买 nike

我正在尝试创建多个不同的 Redux 存储,因为我在“react-redux”中使用 createProvider() 方法。

我已经安装了最新的react-redux版本(7.1.0),但收到类似“createProvider is not Export from react-redux”的错误。当我浏览节点模块时,我无法在react-redux的src中找到createProvider。是版本问题还是我遗漏了代码中的某些内容。我已经向您分享了以下代码片段:

Provider.js

import { createProvider } from "react-redux";

export const STORE_KEY = "myComponentStore";
export const Provider = createProvider(STORE_KEY);

TestComponent.js

import React, { Component } from "react";
import { createStore } from "redux";
import Mycomponent from "./MyComponent";

import { Provider } from "./Provider";

const reducer = {};

const initialState = {
title: "multiple store"
};

const store = createStore(reducer, initialState);

class TestComponent extends Component {
render() {
return (
<Provider store={store}>
<Mycomponent />
</Provider>
);
}
}
export default TestComponent;

Mycomponent.js

import React, { Component } from "react";

import { connect } from "./Connect";

class MyComponent extends Component {
render() {
return <div>{this.props.title}</div>;
}
}

export default connect(function mapStateToProps(state) {
return {
title: state.title
};
})(MyComponent);

最佳答案

好像是deprecatedremoved从V6开始

关于javascript - createProvider 不是从react-redux导出的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56836746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com