react componentDidMount not firing

前端 未结 9 976
南方客
南方客 2020-12-15 14:47

I set up a new react project and for some reason, the componentDidMount method is not being called.

I have verified this behavior by placing a call to

9条回答
  •  悲哀的现实
    2020-12-15 15:43

    I have the create-react-app template. I added the ComponentDidMount into the App Component. I put a console.log and an alert into it. It does not fire and there are no errors in React or the browser. I tried in chrome and firefox.

    FIX: what worked for me was rebooting my pc. Then it started working. I do not know why, but this resolve the issue.

    Update: Not I have an uppercase 'C' it is 'componentDidMount' not 'ComponentDidMount'.. I think it's time for sleep.

提交回复
热议问题