React is a JS UI library that helps build component-based, stateful, performant applications. React itself does not provide UI components. Our component library of choice is Material UI, a React implementation of Google's Material Design. React is used in Gatsby.
- Official docs (read at least Main Concepts and Advanced Guides)
- Redux (read Basics and Advanced)
- React TypeScript cheatsheet
- Start with a completely stateless UI - build the UI elements in JSX, accepting props as needed
- If the component meets the needs then you are done!
- If you need to fetch or calculate data, manipulate props, or manage state, rename your module to
MyModuleTemplate
- Now create a new
MyModule
and add all necessary logic, passing props and handlers toMyModuleTemplate
- Determine module state: do not store derived values in state, calculate them as needed from other state or props
- Determine which module state is transitory and which needs to persist
- When a component disappears from view, transitory state is lost
- State that needs to persist when a component is not visible needs to either be lifted up to a higher component or stored (e.g. in Redux)