Giter VIP home page Giter VIP logo

react-intro-online-web-ft-120919's Introduction

Please note the master branch will be the latest code.. to see code as it was based on a particular lecture, check out the other branches (see what I did there? "check out" the other branches ...? ok sorry I'll stop...)

Other branches:

React!!!!

Today we will:

What is React?

  • a JavaScript library for building interfaces - websites
  • advanced JS
    • React allows us to use the newest features of JS -- even the ones that aren't fully integrated yet
    • introduces JSX
  • it's a way of thinking about the DOM in a modular fashion
    • ...using a virtual DOM (... a further object abstraction of the DOM)
  • a framework made by Facebook -- also open source with awesome documentation
  • always runs in JS strict mode (and even stricter with React.StrictMode!)

Features

Babel & Webpack

  • Babel: transpiler -- allows us to use the latest and greatest JS!
  • Webpack: puts it all together for us

Components

  • a block of re-usable code
  • it represents either, or both:
    • some logic to determine which subsections of the DOM should show up (container)
    • a subsection of the DOM (presentational)
  • one component is build using one of:
    • a JS class
    • a JS function
  • we can use plain JS (.createElement())
  • OR, and BETTER we can use JSX

JSX

What is JSX? A blend of JS and HTML -- looks like HTML tags with the ability to run JS.
A Ruby comparison: ERB A JS comparison: JS template strings

Props

  • are received from a parent or HOC*
  • are immutable -- cannot (should not) be changed by the receiving component

Props are passed with a syntax similar to HTML attributes:

const chevyImpala = {
  make: "Chevy",
  model: "Impala",
  year: 2005,
  miles: 210000
}
// ... inside render(), assuming we're in a class component:
<Car car={chevyImpala} />

In this example, the Car component is receiving a prop called car which will point to the object stored in chevyImpala.

(*HOC = Higher Order Component - a function that takes another component as an argument and returns a new version of that component)

State

  • owned by ONE React component
  • can be passed down to children as props
  • can be changed using this.setState()
  • pre-hooks: only class components can have state!

Let's play!!

Getting started:

run npx create-react-app

react-intro-online-web-ft-120919's People

Contributors

dependabot[bot] avatar howardbdev avatar

Watchers

 avatar  avatar

Forkers

alendor22

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.