part of the code:

constructor(){ super(...arguments); this.state = { cards: this.props.cards, showAddCard: false }; } render(){ console.log(this.state.cards); console.log(this.props.cards); ... } 

this.props.cards is an array

console.log(this.state.cards); - displays an empty array (this is the problem !!!) console.log(this.props.cards); - displays privile array. How to shove the contents of the props in the state ?

  • Are you sure that inside this.props.cards constructor is not empty? - Ilya Paymushkin
  • @ IlyaPaymushkin, I’m sure I put it to check after super() console.log(this.props.cards); - displays a privile array, i.e. not empty. - Ilya
  • You can shove it, the question is different - is it necessary to shove it? - Daniel Khoroshko

1 answer 1

You have a very strange designer. Try replacing it with this:

 constructor(props){ super(props); this.state = { cards: this.props.cards, showAddCard: false }; } 
  • And you have a strange thing in the constructor. Typo should be like this: cards: props.cards, - Denis Bubnov