未捕获的错误:缩小的 React 错误 #200

Sav*_*son 1 html javascript frontend reactjs babeljs

我是 React 初学者,无法调试错误

这是我在 React 中使用组件的代码。

我正在尝试使用图像、标题和链接模拟 google 搜索图像结果,但在浏览器上我看到的只是一个空屏幕。

错误语句是:

Uncaught Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.I.render (react-dom.production.min.js:238)
    at <anonymous>:99:10
    at n (babel.min.js:12)
    at r (babel.min.js:12)
    at o (babel.min.js:12)
    at u (babel.min.js:12)
    at E (babel.min.js:1)
Run Code Online (Sandbox Code Playgroud)

该错误未指定哪一行或任何内容。链接说

你刚才遇到的错误全文是:
目标容器不是DOM元素。

Uncaught Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.I.render (react-dom.production.min.js:238)
    at <anonymous>:99:10
    at n (babel.min.js:12)
    at r (babel.min.js:12)
    at o (babel.min.js:12)
    at u (babel.min.js:12)
    at E (babel.min.js:1)
Run Code Online (Sandbox Code Playgroud)

Ana*_*lop 10

每当您看到此类错误时,您都可以访问它建议查看完整错误的页面。所以,当打开https://reactjs.org/docs/error-decoder.html?invariant=200 时,你可以看到

Target container is not a DOM element,

这意味着您尝试将您的应用程序渲染到错误的 dom 节点中。问题在这里:

var destination = document.getElementsByClassName("container");,

你需要使用getElementById而不是getElementsByClassName