57.3k views
4 votes
If you see the following import in a file, what is being used for state management in the component?

A. Redux.
B. MobX.
C. Context API.
D. useState from React.

User Jorvis
by
7.9k points

1 Answer

2 votes

Final answer:

The import statement is using the Context API for state management in the component.

Step-by-step explanation:

The import statement you see in the file is using the Context API for state management in the component. The other options mentioned in the question, Redux, MobX, and useState from React, are also popular state management solutions in React, but in this case, Context API is being used.

The Context API is a built-in feature in React that provides a way to manage global state in an application without the need for additional libraries.

Here's an example of how the Context API can be used to manage state in a React component:

import React, { createContext, useState } from 'react';

export const MyContext = createContext();

const MyComponent = () => {
const [count, setCount] = useState(0);

return (

{/* Rest of the component goes here */}

);
};

User Daniele Sartori
by
7.8k points

Related questions

1 answer
2 votes
206k views
asked Nov 9, 2024 103k views
Ghanbari asked Nov 9, 2024
by Ghanbari
7.9k points
1 answer
3 votes
103k views
1 answer
1 vote
37.9k views
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.