Trap on the way to use a browserified react script - Invariant Violation: Target container is not a DOM element.
When using a script browserified from a react project, I encountered an error said: Invariant Violation: Target container is not a DOM element.
It confused me for a while. After I moved the HTML script label from head to the end of the body, the problem was solved. It seems that when the script was executed, the related dom element had not been loaded yet.
Then I tried ready function from jQuery, it also works. So when get this kind of error, try to check the position of the script.
评论
发表评论