find-react-legacy-context-usages
v1.0.3
Published
Find usages of React's Legacy Context and generate a report.
Downloads
12,684
Readme
Find React Legacy Context Usages
The title says it. See sample reports in here and here.
Usage
npx find-react-legacy-context-usages \
"./src/**/*.{js,jsx,ts,tsx}" \
--root="./src" \
--report-file="./legacy-context-usages-report.json"
Options
--root
: Root folder for sources where .babelrc
exists.
--report-file
: Report file output path
Important: Don't forget the double-quotes in path glob.
What's supported?
// ClassProperty
class SampleComponent extends React.Component {
static contextTypes = {
darkMode: PropTypes.bool.isRequired,
isLoggedIn: PropTypes.bool.isRequired,
};
static childContextTypes = {
darkMode: PropTypes.bool.isRequired,
isLoggedIn: PropTypes.bool.isRequired,
};
}
// AssignmentExpression
function SampleFunctionalComponent() {}
SampleFunctionalComponent.contextTypes = {
darkMode: PropTypes.bool.isRequired,
isLoggedIn: PropTypes.bool.isRequired,
};
SampleFunctionalComponent.childContextTypes = {
darkMode: PropTypes.bool.isRequired,
isLoggedIn: PropTypes.bool.isRequired,
};
What's not supported?
class SampleComponent extends React.Component {
static contextTypes = someStupidVariableContainingTheContextTypes;
static childContextTypes = someStupidVariableContainingTheChildContextTypes;
}