REACT Flashcards

1
Q

What is React?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are components in React JS?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is State in React?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fragments in React?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between state and props?

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are Higher-Order Components?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly