← All recipes
Moderne licensed

Replace useContext with use

Recipe IDorg.openrewrite.react.19.use-context-hookArtifact@openrewrite/recipes-react

In React 19, useContext is replaced by the use API. This recipe updates both direct and namespace imports.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.react.19.use-context-hook

If the recipe isn’t available locally, install it with:

mod config recipes npm install @openrewrite/recipes-react