Demo Code with Examples for educational purpose
Benefits of using React:
- Speed (virtual DOM)
Unspecific:
- A
import React from "react"
statement is required for JSX to be used react-script
is used to build and run the application- Expects file
public/index.html
andsrc/index.js
%PUBLIC_URL%
is a placeholder for the hosting URL
- Expects file
- JSX elements may be simple JS functions
- React styling expects
className
attributes instead ofclass
for React elements (not components) - If an attibute expects a JS object, remeber to embed it in curly braces, since those are required to state JS code
- Most falsy values like
false
,null
orundefined
won't be rendered and thus can be used for conditional rendering - Dynamically listing React elements requires a
key
property - Props are immutable, thus a component with local state needs to be a class based
- If not using arrow functions in event handler, remeber to bind the function to a class
- Separation of concerns into Presentational and Container Components might result into better code if complexity is high
- Using React Hooks relies on the order of the function calls
Resources:
- Create React App - Set up a modern web app by running one command
- Learn React.js - Full Course for Beginners - Tutorial
- All React Conditional Rendering Techniques
- Four ways to style react components
- Handling Events
- SyntheticEvent - Supported Events
- Lists and Keys
- React v16.3.0: New lifecycles and context API
- Introducing Hooks
- Hooks API Reference - React
- Rules of Hooks - React
- Hooks FAQ - React
- How to fetch data with React Hooks?
- TypeScript and React: Hooks
- How to Use the useReducer Hook
- Material-UI as an alternative to Materialize
Resources:
Resources:
Resources:
React PropTypes:
Flow:
- Flow: A Static Type Checker for JavaScript
- Adding Flow - React
- TypeScript vs Flow - Github
- Remove React PropTypes by using Flow Annotations (in CRA)
- Type Reference | Flow
- Event Handling | Flow
TypeScript:
Conventions:
- Components start with uppercase
- Container Conponents
- Suffix
Container
for a Container Component - Suffix
Component
for a Presentational Component
- Suffix
- Stick to a type of quotes for string literals
Automation: