0

I'm trying to use DND for 2 containers.

1) container have static data form axios => tasks list. 2) container have only tasks which were set to user.

<Container id={1} list={this.props.tasks}/>
<Container id={2} list={this.state.userTasks}/>

When I change user (by select) X => Y I have to refresh data for Container(2).

My this.state.userTasks is refreshing but child component Container(2) still have the same elements.

This is because I use constructor to pass data. Constructor is call once. I know it.

constructor(props) {
        super(props);
        this.state = {cards: props.list};
    }

I can't use componentWillReceiveProps(nextProps) into Container (child) because I have to update only Container(2) and this method is calling when I move element from Container to Container(2)

How to update Container(2) cards when I change user? Do you have any ideas?

marczak
  • 489
  • 2
  • 8
  • 17

1 Answers1

0

I guess you can reset state information of parent component where you are rendering Container components when user information changes

componentWillReceiveProps(nextProps){ if (nextProps.userId !== this.props.userId){ this.setState({userTasks : []})} }

Anil Kumar
  • 11
  • 2