Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
184 views
in Technique[技术] by (71.8m points)

reactjs - Is Lynda's react.js video too out of date to use (based off this error)?

You shouldn't need to view the video to answer my question, but it is available here: http://www.lynda.com/React-js-tutorials/React-js-syntax/379264/413770-4.html

I'm starting to learn react.js for the very first time (I'm pretty skilled in HTML/Javascript already), but the very first simple project is not working correctly.

The example code they give, should output "Hello World" to the page.

<!DOCTYPE html>
<html>
    <head>
        <script src="https://--.--/react-0.13.3.min.js"></script>
        <title>My First React File</title>
    </head>
    <body>
    <script>
        React.render(React.createElement('div', null, 'Hello World'), document.body);
    </script>
    </body>
</html>

Facebook's github has a much more up-to-date react file, 15.0.1, so my code only differs with the updated files:

<!DOCTYPE html>
<html>
<head>
    <script src="https://--.--/react-15.0.1.min.js"></script>
    <script src="https://--.--/react-dom-15.0.1.min.js"></script>
    <title>My First React File</title>
</head>
    <body>
    <script>
        React.render(React.createElement('div', null, 'Hello World'), document.body);
    </script>
    </body>
</html>

Their example outputs "Hello World" correctly, and mine does nothing.

Should I be using a different training to learn React? I feel silly asking a question about such a simple line of code.

PS: I had to censor the file names to meet Stack Overflow standards of not using URL shorteners, but they are the files located here: https://facebook.github.io/react/downloads.html

Edit: I just noticed the video just came out on 2/17/16, so it can't be that out of date.. must be my mistake somewhere? Any help is appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since react v0.14 React.render is not available any more, instead you should use ReactDOM.render()

Reference: https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...