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

React Community - React Kla Meetup 2

React Community - React Kla Meetup 2

Developer Circle Kampala

July 13, 2019
Tweet

More Decks by Developer Circle Kampala

Other Decks in Programming

Transcript

  1. What is a React Component A component is a JavaScript

    class or function that optionally accepts inputs i.e. properties(props) and returns a React element that describes how a section of the UI (User Interface) should appear. Example of a simple React Component
  2. WRITING REACT COMPONENTS You can also use an ES6 class

    to define a component: Example of a class Component
  3. Functional Components • Functional - they are basically functions •

    Stateless - they don’t hold and/or manage state • Presentational - just output UI elements
  4. Class Components • Classes - they are basically classes •

    Stateful - they hold and/or manage state • Smart - they contain logic • Container - hold/contain other components
  5. Choosing a component to use if( • Need to manage

    local state || • Need to add lifecycle methods to your component || • Need to add logic for event handlers ) use class component else always use a functional component
  6. What are Props? Props are React’s way of making components

    easily and dynamically customisable. They provide a way of passing properties/data down from one component to another, typically from a parent to a child component (unidirectional dataflow)
  7. Props with Class Components The number attribute is now accessed

    using this.props.number instead of props.number
  8. What is State State is a JavaScript object that stores

    a component’s dynamic data and determines the component’s behaviour.