子コンポーネントにデータを渡そうとしていますが、未定義の小道具が引き続きあります。私は親コンポーネントの状態を設定するときに問題があるかもしれないと思う。私はcomponentWillMountを使用しないでください。定義済みの状態を通過したときに私の小道具が定義されていないのはなぜですか?
export default class AllItems extends Component {
constructor() {
super()
this.state=({ user: cookie.load('user')})
this.httpHandler = axios.create({
baseURL: 'http://localhost:3000/',
headers: {
'Authorization': this.state.user.token
}
})
}
componentWillMount() {
this.httpHandler('/products/')
.then(function (response) {
this.setState({ winks: response.data.data})
console.log(this.state.winks)
}.bind(this))
}
render() {
return (
<Winks products={this.state.winks} />
)
}
}