Skip to content

Instantly share code, notes, and snippets.

@KaraAJC
Last active August 10, 2016 04:20
Show Gist options
  • Save KaraAJC/7ab5f358fd3c4c8bc9e249837e77000c to your computer and use it in GitHub Desktop.
Save KaraAJC/7ab5f358fd3c4c8bc9e249837e77000c to your computer and use it in GitHub Desktop.
React Test
Why react is great
- load balancing
- code cleanliness
- keep from bloat
react creates components that will keep track of things and update on its own. have their own virtualDOM that lives in between your code and the dom.
learn about JSX
FIRST STEP: Break your app into components! super small!
RESOURCES:
download react developer tools for chrome!
babel.js
get JSX language encoding for sublime for appropriate coloring
this.setState allows you to update the state. this could prevent you from doing something as simple as typing (because that would be changing the state of the page.
AJAX:
React uses One Way Binding not Two Way Binding
Learn about props
JSX lets you use ${term} when setting URL for ajax call, instead of having to concat things
mkdir app_folder
cd app_folder
touch index.html
touch script.js
open editor
add CDN script files:
<script src="https://npmcdn.com/[email protected]/dist/react.min.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/react-dom.min.js"></script>
add script for babel (jsX)
<script src="https://npmcdn.com/[email protected]/browser.min.js"></script>
npm install react react-dom jquery lodash --save
npm install babel-core babel-loader babel-reset-es2015 babel-preset-react babel-preset-stage1 webpack webpack-dev-server gulp gulp-sass --save-dev
in the index.js file:
import React from 'react'
import $ from 'jquery
import ReactDOM from 'react-dom'
to use webpack, create a config file
touch webpack.config.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment