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

Safia Abdalla: Don’t overreact: getting into React

Realm
March 01, 2017

Safia Abdalla: Don’t overreact: getting into React

Video: https://www.youtube.com/watch?v=gobXaxlGw7k&feature=youtu.be

Speaker: Safia a data scientist and software engineer with an interest in open source software and data science for social good. She is one of the maintainers of nteract, a desktop-based interactive computing experience and the organizer of PyData Chicago. In her free time, she enjoys running, working out, and drinking tea.

Abstract: React is a front-end JavaScript framework that’s grown popular over the past few years. Perhaps you’ve used React for a project before or perhaps you're familiar with other front-end frameworks? This talk will explore the technical implementation of React, go through the pros and cons of the framework, and leave the audience with a technically-backed understanding of the best situations to use React in their web applications.

Twitter Link: https://twitter.com/captainsafia

Realm

March 01, 2017
Tweet

More Decks by Realm

Other Decks in Technology

Transcript

  1. What’s up, doc? • Discover the motivations for creating React

    • Discuss the central underlying technical themes of the library • Examine the pros and cons of using the library • Analyze the situations that React is best suite for • Yay! Knowledge!
  2. const AwesomePill = React.createClass({ render: function() { return ( <button

    onClick={this.props.func}> {this.props.value} </button> ); } });
  3. const AwesomePill = React.createClass({ render: function() { this.props.value = ‘new-value’;

    return ( <button onClick={this.props.func}> {this.props.value} </button> ); } });
  4. const AwesomePill = React.createClass({ constructor: function() { this.state = {

    value: ‘not-started’, }; } render: function() { return ( <button onClick={this.props.func}> {this.props.value} </button> ); } });
  5. Lifecycle Methods Mounting • constructor • componentWillMount • render •

    componentDidMount Updating • componentWillReceiveProps • shouldComponentUpdate • componentWillUpdate • render • componentDidUpdate Unmounting • componentWillUnmount
  6. Lifecycle Methods Mounting • constructor • render • componentDidMount Updating

    • componentWillReceiveProps • shouldComponentUpdate • componentWillUpdate • render • componentDidUpdate Unmounting • componentWillUnmount
  7. Lifecycle Methods Mounting • constructor • render • componentDidMount Updating

    • componentWillReceiveProps • shouldComponentUpdate • componentWillUpdate • componentDidUpdate Unmounting • componentWillUnmount
  8. Lifecycle Methods Mounting • constructor • render • componentDidMount Updating

    • componentWillReceiveProps • shouldComponentUpdate • componentWillUpdate • componentDidUpdate Unmounting • componentWillUnmount
  9. Reconciling Elements of Different Types const one = <h1>Hello, #MWDCON!</h1>;

    const two = <h2><Hello, #MWDCON!</h2>; updated(newElement) { if (this.element.type === newElement.type) { replace attributes in element with those in newElement } else { parentNode.replaceChild(newElement, this.element); } }
  10. Reconciling Elements of Different Types const one = <h1>Hello, #MWDCON!</h1>;

    const two = <h2><Hello, #MWDCON!</h2>; updated(newElement) { if (this.element.type === newElement.type) { replace attributes in element with those in newElement } else { replace element with newElement } }
  11. Reconciling DOM Elements of The Same Type const one =

    <p className=”cool”>Cool!</p>; const two = <p className=”way-cool”>Way cool!</p>;
  12. Reconciling DOM Elements of The Same Type const one =

    <p className=”cool”>Cool!</p>; const two = <p className=”way-cool”>Way cool!</p>; updated(newElement) { if element.attributes.length != element.attributes.length update element attributes if element.attributes.values != element.attributes.values update element attributes else return element }
  13. Reconciling DOM Elements of The Same Type const one =

    <p style={ {color: ‘red’ } }>Cool!</p>; const two = <p style={ {color: ‘blue’ } }>Way cool!</p>; updated(newElement) { if (element[attri][key] !== newElement[attr][key]) { element[attr][key] = newElement[attr][key]; } }
  14. Reconciling Component Elements of the Same Type const one =

    <MyComp value=’cool’ action={theCoolness}/> const two = <MyComp value =’way-cool’ action={theWayCoolness}/> update(newElement) { if element.componentName === newElement.componentName) { for (prop in props) { if element[prop] !== newElement[prop] { element[prop] = newElement[prop] } } } }
  15. “We should use React as our front-end library of choice

    because it is so freakin’ awesome!”
  16. “Yes, but it’ll be easy to write tests for our

    UI because React leverages the virtual DOM.”
  17. “Yes, but debugging is easy because we can use things

    like the React Chrome DevTools extension.”
  18. Recap! • Learned about the reasons why React was created

    • Learned some of the core underlying technical concepts in React • Learned about the pros and cons of using the React framework in our projects • Learned about situations where using React can bring the most benefit