Black & White Series

React Components

Thinking in React


React

width:150px

  • https://react.dev/

React Component

Available at: frameworks/react/4-component


HTML Specification

Component Step 1

<div style=>
  <img src={medication1} width="50px"/>
  <h1>Velocirest</h1>
  <p>Description of dosage and frequency of use of Velocirest.</p>
</div>

Resulting Component


Component Predefined

export default function MedicationItem() {
  return <div style=>
           <img src={medication1} width="50px"/>
           <h1>Velocirest</h1>
           <p>Description of dosage and frequency of use of Velocirest.</p>
         </div>
}

Resulting Component


MedicationItem Design

Component Structure


MedicationItem React

width:300px

width:800px


Component Hierarchy

Available at: frameworks/react/5-hierarchy


MedicationItem with Properties

width:300px

width:800px


Component with Properties

export default function MedicationItem({ name, description, image }) {
  return <div style=>
           <img src={image} width="50px"/>
           <h1>{name}</h1>
           <p>{description}</p>
         </div>
}

MedicationList Design

width:1000px


Aggregating Components

export default function MedicationList() {
  return <>
           <MedicationItem name="Velocirest"
                           description="Description of dosage and frequency of use of Velocirest."
                           image="/src/assets/medication1.svg" />
           <MedicationItem name="Tricerabust"
                           description="Description of dosage and frequency of use of Tricerabust."
                           image="/src/assets/medication2.svg" />
           <MedicationItem name="Tyrannotonic"
                           description="Description of dosage and frequency of use of Tyrannotonic."
                           image="/src/assets/medication3.svg" />
         </>
}

Tarefa

  • Baseado no design desenvolvido na tarefa do Figma, crie um componente que crie um componente com que represente a ficha completa do paciente com os medicamentos que ele toma:

width:200px


Tarefa

width:800px


André Santanchè

www.ic.unicamp.br/~santanch/

Web2Learn

santanche.github.io/web2learn/