Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
135
rated 0 times [  142] [ 7]  / answers: 1 / hits: 27629  / 9 Years ago, tue, july 14, 2015, 12:00:00

This is my piece of code, which works correctly (adds records), but throws an error after addition:




Uncaught Error: Invariant Violation: enqueueCallback(...): You called
setProps, replaceProps, setState, replaceState, or
forceUpdate with a callback that isn't callable.




handleSubmit: function(e) {
e.preventDefault();
return $.post('', {page: this.state},
function(data) {
this.props.handleNewPage(data);
return this.setState(this.getInitialState(), 'JSON');
}.bind(this)
);
}


There are no routes for now. Can someone help me to solve this?


More From » reactjs

 Answers
36

The second (optional) parameter to setState is a callback function, not a string. You can pass a function that will be executed once the operation is completed.


[#65815] Saturday, July 11, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
annaw

Total Points: 18
Total Questions: 91
Total Answers: 98

Location: Guam
Member since Fri, Jun 18, 2021
3 Years ago
;