Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to React

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Introduction to React

Avatar for Ivan Jovanovic

Ivan Jovanovic

February 23, 2017
Tweet

More Decks by Ivan Jovanovic

Other Decks in Technology

Transcript

  1. History • Developer by Facebook • Public release at March

    2013 • Influenced by XHP component framework for PHP • Firstly used on instagram.com in 2012 • React-native at March 2015
  2. React features • Declarative • Component-Based • Virtual-DOM • One-way

    data flow • JSX • Hot reloading • Large user group
  3. Pros • Performance • Reusable components • Easy to get

    started • Easy to test • React is not a framework! • Conventions are still developing • Build tools are necessary • Lots of boilerplate code • Licensing • React is not a framework… Cons
  4. React popularity • Most popular framework in 2016 • Used

    by Facebook, Instagram, Netflix, Airbnb, Walmart, Alibaba, Atlassian, Automattic, Microsoft… • Perfect timing • React grows 300%+ every year • Learn once, write everywhere paradigm
  5. React.createClass vs React.Component const Element = React.createClass({ render() { return

    ( <div>Hello</div> ); } }); class Element extends React.Component { constructor(props) { super(props); } render() { return ( <div>Hello</div> ); } }
  6. Components and Props function Welcome(props) { return <h1>Hello {props.name}</h1>; }

    ReactDOM.render( <Welcome name="world">, document.getElementById('root') );
  7. Component state class Clock extends React.Component { constructor(props) { super(props);

    this.state = {date: new Date()}; } render() { return ( <div> <h1>Hello, world!</h1> <h2>It is {this.state.date.toLocaleTimeString()}.</h2> </div> ); } }
  8. Component Lifecycle • Mounting • constructor() • componentWillMount() • render()

    • componentDidMount() • Unmounting • componentWillUnmount() • Updating • componentWillReceiveProps() • shouldComponentUpdate() • componentWillUpdate() • render() • componentDidUpdate()
  9. React native • Build native mobile apps using just JavaScript

    • Styling and positioning is done using Flex boxes • Hot reloading and easier debugging • Use react component lifecycle and methods • Combine your react native app with native components