I have a react component which is basically a form that submits a company's data. Everything is okay till I fill the form but when I submit the form and it goes to the next page it shows the following error:
Warning: setState(...): Cannot update during an existing state transition (such as within `render` or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern but can be moved to `componentWillMount`.
I tried looking for answers in other questions and GitHub but to no avail. My entire code for that component is here:
https://gist.github.com/BikalNepal/b0185dee1528e396ff3a91a4f0caf9bd
I'm aware that this can happen because of setState being an async function
so I tried putting await in front of setStates but that doesn't work either, instead throws some other errors.
Any help would be appreciated. Thank You!
onSubmithandler, it goes to that url to submit the form data. That causes the page to unmount the react component. However, in this case there is asetStatein thehandleFormfunction, which could have caused this error - Leela Venkatesh K