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

React Component Pattern

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

React Component Pattern

Avatar for Juliane Albuquerque

Juliane Albuquerque

September 24, 2019

More Decks by Juliane Albuquerque

Other Decks in Programming

Transcript

  1. “Componentes permitem dividir a interface do usuário em partes independentes

    e reutilizáveis, e pensar sobre cada parte isoladamente.” reactjs.org
  2. class SmallCircleInCircle { constructor() { super() this.state = { smarts:

    “smarts”} } render() { return <SmallCircle {… state} /> } } const SmallCircle = props => <div>{props.smarts}</div> Pequeno círculo no círculo
  3. class SmallCircleInCircle { constructor() { super() this.state = { smarts:

    “smarts”} } render() { return <SmallCircle {… state} /> } } const SmallCircle = props => <div>{props.smarts}</div> Pequeno círculo no círculo
  4. Pequeno círculo no círculo class SmallCircleInCircle { constructor() { super()

    this.state = { smarts: “smarts”} } render() { return <SmallCircle {… state} /> } } const SmallCircle = props => <div>{props.smarts}</div>
  5. Pequeno círculo no círculo class SmallCircleInCircle { constructor() { super()

    this.state = { smarts: “smarts”} } render() { return <SmallCircle {… state} /> } } const SmallCircle = props => <div>{props.smarts}</div>
  6. Pequeno círculo no círculo class SmallCircleInCircle { constructor() { super()

    this.state = { smarts: “smarts”} } render() { return <SmallCircle {… state} /> } } const SmallCircle = props => <div>{props.smarts}</div>
  7. function DottedCircle(AnyCircle) { return class Circle extends React.Component { constructor()

    { super() this.state = { smarts: “smarts”} } render() { return <AnyCircle {…this.state} /> } } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = DottedCircle(SmallCircle)
  8. function DottedCircle(AnyCircle) { return class Circle extends React.Component { constructor()

    { super() this.state = { smarts: “smarts”} } render() { return <AnyCircle {…this.state} /> } } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = DottedCircle(SmallCircle)
  9. function DottedCircle(AnyCircle) { return class Circle extends React.Component { constructor()

    { super() this.state = { smarts: “smarts”} } render() { return <AnyCircle {…this.state} /> } } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = DottedCircle(SmallCircle)
  10. function DottedCircle(AnyCircle) { return class Circle extends React.Component { constructor()

    { super() this.state = { smarts: “smarts”} } render() { return <AnyCircle {…this.state} /> } } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = DottedCircle(SmallCircle)
  11. function DottedCircle(AnyCircle) { return class Circle extends React.Component { constructor()

    { super() this.state = { smarts: “smarts”} } render() { return <AnyCircle {…this.state} /> } } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = DottedCircle(SmallCircle)
  12. class Circle extends React.Component { constructor() { super() this.state =

    { smarts: “smarts”} } render() { return this.props.dashedCircle(this.state) } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = <Circle dashedCircle={state => ( <SmallCircle {...state} /> )} />
  13. class Circle extends React.Component { constructor() { super() this.state =

    { smarts: “smarts”} } render() { return this.props.dashedCircle(this.state) } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = <Circle dashedCircle={state => ( <SmallCircle {...state} /> )} />
  14. class Circle extends React.Component { constructor() { super() this.state =

    { smarts: “smarts”} } render() { return this.props.dashedCircle(this.state) } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = <Circle dashedCircle={state => ( <SmallCircle {...state} /> )} /> this.state
  15. class Circle extends React.Component { constructor() { super() this.state =

    { smarts: “smarts”} } render() { return this.props.dashedCircle(this.state) } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = <Circle dashedCircle={state => ( <SmallCircle {...state} /> )} />
  16. class Circle extends React.Component { constructor() { super() this.state =

    { smarts: “smarts”} } render() { return this.props.dashedCircle(this.state) } } function SmallCircle(props) { return <div>{props.smarts}</div> } const SmallCircleInCircle = <Circle dashedCircle={state => ( <SmallCircle {...state} /> )} />