gpt4 book ai didi

javascript - 无法解析容器中的存储(React、Redux)

转载 作者:行者123 更新时间:2023-12-01 02:23:18 24 4
gpt4 key购买 nike

首先,我想表明我对 JS 和 React 是业余的。我面临的问题是,使用 React-Router 显示的容器未接收存储。我不知道问题是什么。我已经用 Provider 包装了根组件,并且我的应用程序始终显示这样的错误: enter image description here

这是我的应用程序组件的片段:

const rootReducer = combineReducers({
adress: require('./StudiosListRedux').reducer
})

const store = createStore(rootReducer)

const App = ({store}) => (
<Provider store={store} >
<BrowserRouter history={history}>
<Switch>
<Route exact path='/' component={WelcomeScreen} />
<Route path='/main' component={StudiosList} />
</Switch>
</BrowserRouter>
</Provider>
)

这是我的WelcomeScreen 容器:

export class WelcomeScreen extends Component {
state = {
city: '',
street: '',
number: '',
withDrive: false
}

handleCityChange = (text) => {
console.log('city', text)
this.setState({
city: text
})
}

handleStreetChange = (text) => {
console.log('street', text)
this.setState({
street: text
})
}

handleNumberChange = (text) => {
console.log('number', text)
this.setState({
number: text
})
}

handleCheckBoxClick = () => {
console.log('checkbox', 'pushed')
this.setState({
withDrive: !this.state.withDrive
})
}

handleSearchClick = () => {
const { city, street, number, withDrive } = this.state
this.props.fetchStudios('query')
}

render () {
const { city, street, number, withDrive } = this.state
return (
<Container>
<SearchComponent
withDrive={withDrive}
streetValue={street}
cityValue={city}
numberValue={number}
onStreetChange={this.handleStreetChange}
onCityChange={this.handleCityChange}
onNumberChange={this.handleNumberChange}
onCheckBoxClick={this.handleCheckBoxClick}
onSubmitClick={this.handleSearchClick}
/>
</Container>
)
}
}

export const mapStateToProps = state => {
destination: state.adders.toJS()
}

const mapDispatchToProps = {
fetchStudios: StudiosActions.studiosRequest
}

export default connect(mapStateToProps, mapDispatchToProps)(WelcomeScreen)

谁能帮我解决我的问题吗?我应该怎么做才能为我的容器提供存储?

最佳答案

ReactDOM.render(<App store={store} />, document.getElementById("root"))

您似乎忘记将商店传递给应用程序。我可能是错的,除此之外可能还有其他原因,

关于javascript - 无法解析容器中的存储(React、Redux),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49032331/

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