React.js


React official blog

https://facebook.github.io/react/blog/


React.js environment for development

React.js environment for development

React.js examples

React.js testing


New react app can be created by next command

$ npx create-react-app myApp


Component life cycle

componentWillMount
componentDidMount

componentWillUnmount

componentWillReceiveProps(nextProps)
shouldComponentUpdate(nextProps, nextState)
componentWillUpdate(nextProps, nextState)
componentDidUpdate(prevProps, prevState)


Possible SPA routing script

const express = require('express');
const path = require('path');

const server = express();

server.use(express.static('public'));

server.get('*', (req, res) => {
  fs.readFile(`${__dirname}/dist/index.html`, (err, html) => {
    if (error) throw error;

    res.setHeader('Content-Type', 'text/html');
    res.end(html);
  });
});

server.listen('8080', () => {
  console.log('Express listening on port 8080');
});