Answer the question
In order to leave comments, you need to log in
Why is parent not updating in ReactJS?
Good time of the day. You need to update the Parent component.
What I do: Move a card from one column to another:
moveCard = async (type, id) => {
const { list_id } = this.props;
if (type === "left") {
const response = await moveCard("left", id, list_id); //axios patch request
this.sub.send({
list_id: list_id,
card: {
id: response.id,
created_at: response.created_at,
updated_at: response.updated_at,
list_id: response.list_id,
title: response.title,
moved_card: 'true'
}
});
} else if (type === "right") {
const response = await moveCard("right", id, list_id);
this.sub.send({
list_id: list_id,
card: {
id: response.id,
created_at: response.created_at,
updated_at: response.updated_at,
list_id: response.list_id,
title: response.title,
moved_card: 'true'
}
});
}
}
let ids = [];
this.state.cards.map(card => {
ids.push(card.id);
return null;
});
const cardIndex = ids.indexOf(data.card.id);
const cards = update(this.state.cards, { $splice: });
cards.shift();
this.setState({ cards: cards });
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question