亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

大佬們遇到過這個問題嗎?react-dedux用Provider,組件this.props獲取不到store求解答!

大佬們遇到過這個問題嗎?react-dedux用Provider,組件this.props獲取不到store求解答!

呼啦一陣風 2019-09-09 20:28:16
index.js部分constApp=lazy(()=>import('./component/home/App'))constPageA=lazy(()=>import('./component/page-a/Component'));conststore=createStore(Reducers);console.log(store)//路由constRoot=({store})=>();ReactDOM.render(Root(store),document.getElementById('root'));store打印出來是有的在App組件里面只打印this.props只打印出來了history的值
查看完整描述

2 回答

?
蕪湖不蕪

TA貢獻1796條經驗 獲得超7個贊

constRoot=(store)=>(
Loading...
}>
);
                            
查看完整回答
反對 回復 2019-09-09
?
蠱毒傳說

TA貢獻1895條經驗 獲得超3個贊

組件還需要被connect起來,聲明要獲取store里的哪些字段
import{connect}from'react-redux'
classComponentextendsReact.Component{
render(){
console.log(this.props)
}
}
constmapStateToProps=state=>{
return{哪些你需要的值}
}
constmapDispatchToProps={
...
}
exportdefaultconnect(mapStateToProps,mapDispatchToProps)(Component)
                            
查看完整回答
反對 回復 2019-09-09
  • 2 回答
  • 0 關注
  • 338 瀏覽
慕課專欄
更多

添加回答

了解更多

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號