Я пытаюсь передать данные дочернему компоненту, и я продолжаю получать неопределенную опору. Я думаю, что это может быть проблемой, когда Im устанавливает состояние в родительском компоненте. Должен ли я не использовать 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} />
)
}
}