Git Product home page Git Product logo

todolist-react.js's Introduction

TodoList-React.js

This project was created to learn how to make web-apps using Express.js framework with React.js components.

Screenshots:

pic1 pic2

Instructions

To install all required packages write in your command line:

npm install

To compile React components write:

webpack -w

To start application write:

npm start

And open in browser http://localhost:3000/


React + Express little tutorial

  1. Create folder for your project

  2. Inside this folder create Express project:

$ express --view=<view>

where you have to put your view engine on the place of <view>. For example you can write $ express --view=ejs to create a project with ejs view engine.

  • PS: to be able to run this command, you need to have express generator installed globally on your computer. Do do this you have to execute in command line $ npm install express-generator -g. For more information about express generator you can visit this page: https://expressjs.com/en/starter/generator.html

  1. Install all node modules that are needed:
$ npm install

  1. Install React:
$ npm install react --save

  1. Install ReactDOM:
$ npm install react-dom --save

  1. Install webpack:
$ npm install webpack --save-dev
  • PS: later you will need to have webpack installed globally on your computer. Do do this you have to execute in command line $ npm install webpack -g.

  1. Install Babel Core:
$ npm install babel-core --save-dev

  1. Install Babel Loader:
$ npm install babel-loader --save-dev

  1. Install Babel Presets:
$ npm install babel-preset-react --save-dev
$ npm install babel-preset-es2015 --save-dev

  1. Create webpack.config.js file inside project folder:
var webpack = require('webpack')
var path = require('path')

module.exports = {
    entry: {
        app: './public/app/App.js'
    },
    output:{
        filename: 'public/build/bundle.js',
        sourceMapFilename: 'public/build/bundle.map'
    },
    devtool: '#source-map',
    module: {
       loaders: [
           {
               test: /\.jsx?$/,
               exclude: /(node_modules|bower_components)/,
               loader: 'babel-loader',
               query:{
                   presets: ['react','es2015']
               }
           }
       ]
    }
}

  1. Create app folder with react components and configure paths:
  • PS: The simplest component that is rendering into div with id="app" will look like this:
import React, { Component } from 'react'
import ReactDOM from 'react-dom'

class App extends Component {
	render() {
    return(
        <div>
          <h1>Hello world!</h1>
        </div>
    )
	}
}

ReactDOM.render(<App />, document.getElementById('app'))

  1. Import your components inside view:
  • PS: The simplest component that use previous component will look like this:
<!DOCTYPE html>
<html>
  <head>
  <meta charset="utf-8">
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
  </head>

  <body>
  	<div id="app"></div>

    <script type="text/javascript" src="/build/bundle.js"></script> 
  </body>
</html>

  1. Run webpack to compile your react components and wach their changes:
$ webpack -w

  1. To run the app write in other command line tab:
$ npm start

  1. Open in your browser on http://localhost:3000/ and enjoy your app with react component and express back-end

Good luck! :)

todolist-react.js's People

Contributors

kovdimay avatar

Watchers

James Cloos avatar

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.