Consider the following Code Snippet

const withLoading = (WrappedComponent) => {

return function WithLoading(props) {

const [loading, setLoading] = React.useState(true);

React.useEffect(() => {

setTimeout(() => {

setLoading(false);

}, 2000);

}, []);

return loading ? <p>Loading...</p> : <WrappedComponent {...props} />;

};

};

const DataComponent = () => <p>Data Loaded!</p>;

const WrappedDataComponent = withLoading(DataComponent);

What does the withLoading HOC do to the DataComponent?

It creates a HOC that delays rendering until data is loaded

It demonstrates how to handle loading states using a Hook.

It creates a HOC that renders "Data Loaded!" immediately.

It illustrates how to use a HOC to fetch remote data.

Verified Answer
Correct Option - a

To get all Infosys Certified React Expert Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in