Answer the question
In order to leave comments, you need to log in
Why can't I put props in the state and send this state to the child component?
A number comes to the props of this component on click (initially null),
If you pass < Work update={this.props.update}/ > as props below, then everything works
If you pass < Work update={this.state.update}/ > as state does not work.
The question is why does it work this way?
I'm reassigning a prop to a state, and I want to use the state to pass it to the component below, why is it just passing empty to me?
In the < Work/> component, it simply renders as < div>{this.props.update}< /div>
import React, { Component } from 'react'
import Work from '../Work'
export default class ArticleList extends Component {
constructor(props) {
super(props);
this.state = {
update: this.props.update
}
}
render() {
var workList = (
<Work
update={this.props.update}
/>
)
return workList
}
}
Answer the question
In order to leave comments, you need to log in
If you pass < Work update={this.state.update}/ > as state then it doesn't work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question