Reactjs Redux get store.getState()未定义
我正在从react中的常规有状态组件迁移到reduxing。当我尝试在返回函数中向下运行Reactjs Redux get store.getState()未定义,reactjs,react-native,redux,Reactjs,React Native,Redux,我正在从react中的常规有状态组件迁移到reduxing。当我尝试在返回函数中向下运行console.log store.getState()时,它显示为未定义状态。我不确定我在这里做错了什么。任何帮助都将不胜感激 const store = createStore(reducers, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()); class Products ext
console.log store.getState()
时,它显示为未定义状态。我不确定我在这里做错了什么。任何帮助都将不胜感激
const store = createStore(reducers, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
class Products extends React.Component {
constructor (){
super();
this.state = {
productImages: [],
fetching: false
}
}
componentDidMount(){
this.setState({
fetching: true,
});
fetch('https://omenu.com/test/jsonimages')
.then(response => response.json())
.then(products => products.map(product => product.image))
.then(products => store.dispatch(addLink(products)))
.catch(err => console.log(err))
}
render(){
return(
<Provider store={store}>
{console.log(store,"Store")} //having a problem here ----- It showing undefined
<ScrollView horizontal={true}>
<ActivityIndicator size="large" style={styles.spinner} animating={true}/>
{this.state.productImages.map((uri,i)=>(
<Image style={styles.thumb} key={i} source={{uri}}/>
))}
</ScrollView>
</Provider>
)
}
}
const store=createStore(还原器,窗口.uuu REDUX_DEVTOOLS_EXTENSION_uu&&window.uuu REDUX_DEVTOOLS_EXTENSION_uu());
类产品扩展了React.Component{
构造函数(){
超级();
此.state={
productImages:[],
抓取:假
}
}
componentDidMount(){
这是我的国家({
真的,
});
取('https://omenu.com/test/jsonimages')
.then(response=>response.json())
.then(products=>products.map(product=>product.image))
.then(产品=>store.dispatch(添加链接(产品)))
.catch(err=>console.log(err))
}
render(){
返回(
{console.log(store,“store”)}//这里有一个问题------它显示未定义
{this.state.productImages.map((uri,i)=>(
))}
)
}
}
从何处导入存储?添加链接接缝也未定义..+你的减速机申报表在哪里?