Skip to content

deleav/react-test

Repository files navigation

React 學習筆記

1. Using React from npm

  • 兩種方法

    • 使用browserify
    • 使用webpack
  • 使用 browserify

    $ npm install --save react react-dom babelify babel-preset-react
    $ browserify -t [ babelify --presets [ react ] ] main.js -o bundle.js
    
  • 使用 webpack

    $ npm install --save react react-dom babel-preset-react
    $ webpack
    
  • code

    // main.js
    var React = require('react');
    var ReactDOM = require('react-dom');
    
    ReactDOM.render(
      <h1>Hello, world!</h1>,
      document.getElementById('example')
    );

2. Quick Start Without npm

  • 下載React

  • code

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <title>Hello React!</title>
        <script src="build/react.js"></script>
        <script src="build/react-dom.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
      </head>
      <body>
        <div id="example"></div>
        <script type="text/babel">
          ReactDOM.render(
            <h1>Hello, world!</h1>,
            document.getElementById('example')
          );
        </script>
      </body>
    </html>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published