use-context-hook
Transform React.useContext() and useContext() calls into use().
Usage
bash
Development
bash
Explore community-led codemods to migrate, optimize, and transform your codebase.
Build your own codemod and share it with the community.
Transform React.useContext() and useContext() to use() hook
npx codemod @react-new/use-context-hook
Transform React.useContext() and useContext() calls into use().
bash
bash
This is one example from the codemod's test cases. The codemod may handle many more cases.
Build your own codemod and share it with the community.
1 import React from "react";
2 import ThemeContext from "./ThemeContext";
3
4 function Component({
5 appUrl,
6 }: {
7 appUrl: string;
8 }) {
9 const theme = React.useContext(ThemeContext);
10 return <div />;
11 };