bitovi / academy

Everything we know about frontend, backend, UX, and Devops consulting and management.
https://www.bitovi.com/academy/
14 stars 3 forks source link

React Way Notes: 2019-09-02 #179

Open justinbmeyer opened 5 years ago

justinbmeyer commented 5 years ago

General Guidelines

justinbmeyer commented 5 years ago

State management

Managing state via hooks directly in the component

Custom Hooks and Hook / Provider Pairs

function paginate(limit) {
  const [ count, setCount ] = useState();

  return {
    next(){ ... },
    prev(){ ... },
    get page(){ ... }
  }
}

Adding a Provider

justinbmeyer commented 5 years ago

Data Modeling

Simple Models

Things that would be interesting to show:

How to unify state changes across multiple components.

Could your models call useState?

class Todo {
  static todosById = {};
  static get(id){
    const [ todo, setTodo ] = useState();
  }
}

function EditTodo(){
  const [todo, setQuery]
}