I want to invoke a method but in meantime it give me an error:
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
Function Declaration
datahandler= (val1,val2) => {
this.setState(
{
dataNew:
this.state.dataNew=== {val1} ? {val2} : {val1}
},
() => {
this.getNew();
}
);
};
Function Calling
<Table.HeaderCell onClick={this.datahandler('name asc','name desc')}>
Click Me to Call
</Table.Headercell>