Skip to content

Instantly share code, notes, and snippets.

@yi-mei-wang
Created October 17, 2019 09:38
Show Gist options
  • Save yi-mei-wang/0012b88e40e61570c9a5c966d24d76e4 to your computer and use it in GitHub Desktop.
Save yi-mei-wang/0012b88e40e61570c9a5c966d24d76e4 to your computer and use it in GitHub Desktop.
React recap
  1. Syntax of functions (declaration with function keyword vs arrow functions)

  2. Passing props to direct children (one level)

  3. Passing props down to grandchildren (multiple levels)

<NameOfComponent nameOfProp={name of value or function}/> > <Container handleClick={this.handleClick}/> > <Button handleClick={props.handleClick}/>

  1. Import components from another file import <name of component> from "<name of the file that contains the component>";

  2. event comes from the browser onClick={e => props.handleClick(e)} e => props.handleClick(e) is an anonymous function

  3. You can totally pass a function down as props

  4. this.props, this.functionName, ... are only for class components; otherwise if you have a functional component, you would refer to your props as just props

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment