Sometimes, I want to use a React Hook in an existing class component


Sometimes, I want to use a React Hook in an existing class component.

Two options:
1. Convert the class to a function
2. Wrap the Hook in a higher-order component

Option 2 is typically around 5 lines of code. 😎

#reactjs

View original on X