简体   繁体   中英

Trying to understand warning messages I get when using babel for react.js

I have made a simple react rendering function that prints out hello in a div tag with the id of "react-container". The only problem is that I keep getting warning messages in the console like

unreachable code after return statement

or

mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create

All of this is coming from the babel-core browser.js script I inserted into the document. I'm trying to figure out what it means, am I doing something wrong, or should I just ignore it

    <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>REACT 1</title>
    <script src="react-15.2.1.js"></script>
<script src="react-dom-15.2.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
  </head>
  <body>
    <div id="react-container">

    </div>
<script type="text/babel" >

 ReactDOM.render(<h1>hello</h1>, document.getElementById('react-container'));
</script>
  </body>
</html>

This is the default behavior of the Firefox developer console. More advanced debugging environments like the Chrome console don't show warnings like these. You can disable the linting of scripts in Firefox by clicking on this button:

在此处输入图片说明

A "warning" is simply that: A warning that there might be a potential issue with the syntax of code. In this case the warnings are harmless, and because they come from third party scripts, there's not much you can do about it. Especially the second one, which is really more of an opinionated code style.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM