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

Introduction to ReactJs

Introduction to ReactJs

Low-level introduction to React, how components are created, and how they can integrate with Angular and Node.

Anthony Pipkin

July 21, 2015
Tweet

More Decks by Anthony Pipkin

Other Decks in Technology

Transcript

  1. SMALLER UPDATES User makes a request Server builds page Server

    sends it back User triggers a change Server builds the response Server sends it back
  2. CLIENT-SIDE TEMPLATING User makes a request Server builds page Server

    sends it back User triggers a change Server builds the response data Server sends it back Client compiles UI from template
  3. CLIENT-SIDE TEMPLATING User makes a request Server builds page Server

    sends it back User triggers a change Server builds the response data Server sends it back Client compiles UI from template
  4. https://facebook.github.io/react/docs/why-react.html React is a JavaScript library for creating user interfaces

    by Facebook and Instagram. Many people choose to think of React as the V in MVC. We built React to solve one problem: building large applications with data that changes over time.
  5. https://facebook.github.io/react/docs/why-react.html React challenges a lot of conventional wisdom, and at

    first glance some of the ideas may seem crazy. Give it five minutes
  6. REACT ELEMENT var el = React.createElement(‘a’, { href: ‘/about/‘, className:

    ‘nav’ }, [‘About Us’]); JS createElement(type, props, children);
  7. REACT ELEMENT var el = React.createElement(‘a’, { href: ‘/about/‘, className:

    ‘nav’ }, [‘About Us’]); var el = (<a href=“/about/“ className=“nav”>About Us</a>); JSX JS createElement(type, props, children);
  8. REACT COMPONENT var link = React.createClass({ render: function () {

    return ( <a href=“/about/“ className=“nav”>About Us</a> ); } });
  9. SIMPLE DEMO http://jsbin.com/buwoba/edit?js,output var Header = React.createClass({ render: function ()

    { return ( <span>{this.props.name}</span> ) } }); React.render(<Header name="Atlanta Full Stack" />, document.getElementById('app'));
  10. SLIGHTLY MORE COMPLICATED DEMO http://jsbin.com/rezabe/edit?js,output var Event = React.createClass({ getDefaultProps:

    function () { var _date = new Date(); return { name: 'Sample Name', date: _date, time: _date }; }, render: function () { return ( <div> <Header name={this.props.name} /> <DateTime date={this.props.date} time={this.props.time} /> </div> ); } });
  11. INTEGRATES WITH ANGULAR http://jsbin.com/pokidat/6/edit?js,output app.directive('appHeader', function () { return{ restrict:

    'E', scope: '=', link: function (scope, el, attrs) { React.render(<Header name={attrs.headername}/>, el[0]); scope.$watch('headerName', function (newVal, prevVal) { React.render(<Header name={newVal}/>, el[0]); }); } }; });
  12. WORKS ON NODE.JS var handlerFn = function (request, reply) {

    reply( React.renderToStaticMarkup( React.createElement(Header, { name: "Atlanta FullStack” }) ) ); };
  13. WHO IS USING REACT Facebook Instagram Yahoo Atom Khan Academy

    Squarespace Codeacademy Hipchat Netflix Paypal Ebay Airbnb BBC Flipboard Salesforce many, many more