I have 2 component, one parent, another is child component
in my parent component I'm using react-table and inside using some component where defined react-table like
Filter: props => <FilterInnerComponent {...props} />,
problem is in my child component I'm changing some state to true or false on click to some button. And when my data changes in my parent component. My child component too re-rendering and child component state back to default.
How to prevent this and keep the state of child component on last changes when parent component state change.
i research and see some resolution about :
shouldComponentUpdate(nextProps, nextState) {
}
but I don't know how using it. I tried this but not helped.
shouldComponentUpdate(nextProps, nextState) {
return this.state.openTextBox != nextState.openTextBox
}
here is where i'm using my onClick function where i change my openTextBox value on my child component
changeFilterType(event) {
if(filterType !== "All"){
this.state.openTextBox = true
}
else{
this.state.openTextBox = false
}
}
this.props.openTextBox != nextProps.openTextBox
– Pardeep Dhingra