Skip to content

Instantly share code, notes, and snippets.

@C-Bandstra
Last active May 2, 2020 22:26
Show Gist options
  • Save C-Bandstra/25cd0b21567e44d34b13b1a92e485416 to your computer and use it in GitHub Desktop.
Save C-Bandstra/25cd0b21567e44d34b13b1a92e485416 to your computer and use it in GitHub Desktop.
Mod 3 Pre-Work

Framework vs. Library

  • A framework is kind of like a boiler plate to build applications on.

  • A library is a bunch of reusable code that you can choose to access quickly to save time.

  • The difference between a framework and a library is that a framework calls your code and your code calls the library

Why use a framework?

Using frameworks allow you to spend less time on reinventing code and more time focusing on unique features.

What is a "component" in React? Why is it useful to have components?

  • Functional Components optionally take in properties, do not hold/manage state, and only output UI elements

    const Greeting = () => <h1>Hi, I’m a functional component</h1>;
  • Class Components can contain logic, hold/manage state, usually hold numerous components (mostly functional)

    class Greeting extends React.Component {
     render(){
       return <h1>Hi, I’m a class component!</h1>;
     }
    }

Components are useful because they are independent and reuseable. They work like functions but work in isolation and return HTML elements

React Props

Props stand for properties which are used to pass data from one component to another. You can make the property optional by giving a f]deafult property value to the component. The props should be considered immutable.

React State

State is keeping track of data values in between renders. The state gets its initial data from the constructor's super method. this data can be hard coded or be used from props. State will be changed when the component is rendered.

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