Skip to content

Instantly share code, notes, and snippets.

@sathishpaul
Last active January 30, 2016 21:18
Show Gist options
  • Save sathishpaul/ab9c49a354d0b13b7572 to your computer and use it in GitHub Desktop.
Save sathishpaul/ab9c49a354d0b13b7572 to your computer and use it in GitHub Desktop.
Notes from the discussion we had about React.js

React.js overview

  • View library for building UI
  • Idea is to build composable and stateful UI components
  • React auto updates only the changed-parts of the UI when state changes
  • Uses Virtual DOM and synthetic events to manage UI updates
  • Uses JSX to represent components
    • HTML code in Javascript

Essential things to remember

  • render() method required for each component

    • specifies UI items that a component should render
  • this.props

    • is a simple JS object
    • represents the set of inputs from parent component
    • immutable
  • this.state

    • represents the internal state of a component
    • can be changed using setState({key: newValue})
    • calling setState() automatically invokes render() on the component
      • intelligent diff ensures that only the
  • this.refs

    • holds references to DOM nodes
    • useful to get references to form elements like input, checkbox etc
    • possible to get away without using this, but available if needed
  • Code example

  • Thinking in React

    • Start with making application state as one big tree
    • Break down UI into components - each with its props and state
    • Need to use many small libraries that each do one thing well, for building the app
  • Note on ES6

    • Latest version of JavaScript language
    • Spec formalized last year, most browsers have implemented 90% of spec
    • Highlights: arrow function, array spread operator, destructuring etc
    • Babel - transpiler, converts ES6 code to ES5 so it can be run on all browsers
    • Webpack
      • module bundler
      • analyses dependency tree of components
      • flattens out imports
  • Redux (http://redux.js.org/index.html)

  • Immutable.js (https://github.com/facebook/immutable-js)

    • JavaScript Collections library that support Immutable Collections
    • Works well with the idea of React and Virtual DOM diff. Helps in efficient object comparison.
    • Ensures data flow is predictable

Reading Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment