Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOC: add Use Cases #754

Merged
merged 7 commits into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/hoc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ title: HOC Cheatsheet
- Render props may be considered in the future
- The goal is to write HOCs that offer type safety while not getting in the way.

There are a lot of use cases where an HOC is used. For example:

- HOCs can wrap components to check if a user is authenticated before rendering, or to restrict access based on user roles.
- An HOC can conditionally render components based on feature flags or A/B testing.
- An HOC can provide translation functionality to components.
- An HOC can add logging or analytics tracking to components without modifying their core logic.

Here is a base HOC example you can copy right away:

```jsx
Expand Down