REACT Flashcards
What is React?
A front-end JavaScript library for building user interfaces. It was developed by Facebook and is maintained by both Facebook and the coding community. Easy to use and excellent support
What are components in React JS?
Small pieces of the library which allows you to split the UI into independent reusable parts. There are two types: Class-based (outdated and no longer used) and functional component (imported from React () => {}.
They are simple JavaScript functions that accepts props and returns a React element. After the introduction of React Hooks, writing functional components has become the standard way of writing React components in modern applications.
What is State in React?
The state is a built-in React object that is used to contain data or information about the component. A component’s state can change over time; whenever it changes, the component re-renders.
It allows us to manage changing data in an application by defining key-value pairs specifying various data we want to track in the application
To declare state using React Hooks, we need to use the useState hook. The useState hook accepts a parameter which is the initial value of the state.
Fragments in React?
A common pattern in React is for a component to return multiple elements. Allows you to wrap or group multiple elements without adding an extra node to the DOM. This can be useful when rendering multiple child elements/components in a single parent component. Fragments let you group a list of children without adding extra nodes to the DOM.
What is the difference between state and props?
While both hold information that influences the output of render, they are different in one important way: props get passed to the component (similar to function parameters) whereas state is managed within the component (similar to variables declared within a function).
What are Higher-Order Components?
an advanced technique in React for reusing component logic. HOCs are not part of the React API, per se. They are a pattern that emerges from React’s compositional nature. Concretely, a higher-order component is a function that takes a component and returns a new component.