← React Intermediate Questions - Set 1 Q1
What are higher-order components (HOCs) in React?
React Intermediate Questions - Set 1
Example
1
2
const withLoading = (C) => ({ loading, ...rest }) =>
loading ? <Spinner /> : <C {...rest} />;
What to notice
- Reusable cross-cutting behaviour, at the cost of an extra wrapper per feature.
← Back to the question list