Git Product home page Git Product logo

masterclass-react-redux's Introduction

Getting started with a React application

Presentation

http://slides.com/joostlubach/react

Example app

What we'll be using:

  • Babel to convert ES2015 JSX files to ES5 files
  • Webpack to create a single JS file for the browser
  • Webpack dev server to load our web page

To create this project template from scratch:

# Install system-wide prerequisites
npm install -g yarn webpack webpack-dev-server

# Create an app directory
mkdir react-app
cd react-app

# Initialize the app directory
npm init
yarn

# Add required development packages
yarn add -D babel-core babel-preset-react babel-loader

# Add required runtime packages
yarn add react

# Create .babelrc file (just copy-paste this line)
echo -e "{\n  \"presets\": [\"react\"]\n}" >.babelrc

# To view the created file:
cat .babelrc

# Create webpack.config.js
# I created a Gist for this at https://gist.githubusercontent.com/joostlubach/30955f971560c06bf77f759442b3515f/raw/194a87ec4732b1b8dc1f482956f2334213b08fcc/webpack.config.js
# Either download it and save it as webpack.config.js in your directory, or if you have wget, type:
wget https://gist.githubusercontent.com/joostlubach/30955f971560c06bf77f759442b3515f/raw/194a87ec4732b1b8dc1f482956f2334213b08fcc/webpack.config.js

# To view the created file:
cat webpack.config.js

# Create an empty src and build directory
mkdir src build

# Create an empty index.js file
echo '' >src/index.js
  • Now create an index.html page inside the build directory:
<!doctype html>

<html>
  <head>
    <title>React example</title>
  </head>

  <body>
    <main></main>
    <script type="text/javascript" src="./bundle.js"></script>
    <script src="/webpack-dev-server.js"></script>
  </body>
</html>
  • Finally, start up your web server!
webpack-dev-server --content-base build --inline

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.