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.

评论

此博客中的热门博文

Openwrt路由器上配置shadowsocks透明代理+gfwlist(PAC)

Configure shadowsocks transparent proxy + gfwlist(PAC) on OpenWRT Router

Using Haproxy + shadowsocks (ha + ss) to setup multi ss backend and load balance