score:1

Accepted answer

if the "state" you're after is already in react router, then copying it to your own state is unnecessary duplication, and the cause of your error (trying to update the state during render. you're better off just grabbing the state from the react router. you can use a route without a path for that

<route render={({ location }) => (
   // this will render whenever the location changes
   <yournavigationbar location={location} />
  )}
/>

score:0

you use a setstate in react lifecycle. you call your method updateactivepath in render or other lifecycle method react. this trigger an extra rendering for your component.

for fix this warning change your setstate location in componentwillmount method or in function call by action (click, ...).

for must information go to lifecycle component documentation: https://reactjs.org/docs/react-component.html


Related Query

More Query from same tag