Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.33 KB

react.md

File metadata and controls

34 lines (28 loc) · 1.33 KB

React

Is a library for building UIs.

Components, instances, and elements

  • Components
  • Instances - instances of a Component, just like instances of a class
  • Elements
    • "plain object describing a component instance or DOM node and its desired properties."

    • An Element "takes props as an input, and returns an element tree as the output"

    • they usually belong in the the render() method of a Component

    • it looks like this: {type: someType, props: someProps}

    • type can be a Component (BigButton) or a name of a DOM node ('button')

    • props key contains a children key, which can be a text node or an array of Elements

      // an element as plain object (theory):
      {
        type: Button,
        props: {
          children: 'Sign up'
        }
      }
      // and in JSX (practice):
      <Button>Sign up</Button>

sources: