Skip to content

Commit

Permalink
HOC: add Use Cases (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
shxntanu authored Oct 19, 2024
1 parent 15c1f00 commit 8459140
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit 8459140

Please sign in to comment.