Skip to content

Instantly share code, notes, and snippets.

@mapsam
Last active December 11, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapsam/96bcda7557e97802a00c to your computer and use it in GitHub Desktop.
Save mapsam/96bcda7557e97802a00c to your computer and use it in GitHub Desktop.
Learning React

Starting with the tutorial straight from Facebook: https://facebook.github.io/react/docs/tutorial.html

  • successfully installed with git clone https://github.com/reactjs/react-tutorial.git
  • required npm install
  • successfully started server running node server.js - viewing at localhost:3000
  • my first Ah-ha is that React can essentially be used to consume a custom API and render components via React components. They are not DOM nodes, apparently - React components are their own thing.
  • react-dom (ReactDOM) gives you DOM-specific methods, while react (react native) gives you React methods.
  • nesting components is super awesome, and now starting to click how to pass data down the pipe with this.props
  • linking a JSON data source to the components now. Apparently props are immutable, meaning that if we change one it won't change down the pipe. This means we use this.state, which can be updated by running this.setState() and passing in parameters based off the component's needs.
  • cool functionality of passing actual functions down the Component chain via properties in the component (i.e. <Component functionName="this.functionDefinition" />) - you can access this in the ChildComponent via this.props.functionName
  • GOTCHA: the FB tutorial uses babel for running the JSX compiler, which means your <script> tags must use type="text/babel" instead of text="type/javascript"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment