Basics of React - LucyMHall/Fizzy_O GitHub Wiki

Components

  • The building blocks of a React App
  • A component is a JavaScript class/function that optionally accepts inputs e.g. properties(props and returns a React element that describes how it should look:
  • You can have functional components and class components

When should you use a functional component?

  • when what you are writing doesn't hold or manage states
  • pretty much all the do is presentational stuff ( take properties and output UI elements which are rendered to the page)
  • e.g. const Greeting = () => <h1>Hi, I’m a dumb component!</h1>;

When should you use a class component?

  • When dealing with state

Basic Components:

  • Text - displays text
  • View - layout/positioning
  • Image - displays images
  • TextInput - user input via keyboard
  • ScrollView - creates a container which can host multiple components and views
  • StyleSheet - bit like a CSS stylesheet
  • Button
  • Picker
  • Slider
  • Switch - renders a boolean input
  • Alert
  • Linking
⚠️ **GitHub.com Fallback** ⚠️