ReactJS — Key Concepts from a Noob
What is ReactJS??
- Components are everything
Components in ReactJS are reusable, composable, and stateful —we can think of them as functions. There are two types of components: container components (smart components) and presentational components (dumb components). Unlike container components, presentational components generally do not keep track of state.
2. Props vs. State
ReactJS monitors if there are any changes to a components’ state through the use of a virtual DOM — if a change is detected, rather than reloading the entire page, it “reacts” to the change by invoking the render( ) function and only updating that specific components’ data.
3. Lifecycle Methods
Lifecycle methods are reserved components provide by the ReactJS library that will run logic before or after rendering (`componentWillMount` vs. `componentDidMount`), that can be applied to components in order to free up resources, and to describe the order of when things should happen.
Good use case for ReactJS
ReactJS is good tool to build Single Page Applications (SPA) because they follow similar logic — a SPA loads once and when data is requested, the client only sends a request for the data the user is asking for; this avoids unnecessary page reloads, making the application more efficient, and in turn provides the user with a better overall experience.