Registry
C

react-router/4/move-hoc-to-global-scope

No description available

Codemod3 executions

  • Legacy
  • react
  • react router
  • migration
Connect a repo
npx codemod react-router/4/move-hoc-to-global-scope

Moves HOC calls to the global scope

Example

Before

ts
<Router history={browserHistory}>
    <Switch>
        <Route
            path='/'
            render={(props) => (
                <Route
                    exact
                    path='/a'
                    component={HOC(PageComponent)}
                />
            )}
        />
    </Switch>
</Router>;

After

ts
const HOCPageComponent = HOC(PageComponent);
<Router history={browserHistory}>
    <Switch>
        <Route
            path='/'
            render={(props) => (
                <Route
                    exact
                    path='/a'
                    component={HOCPageComponent}
                />
            )}
        />
    </Switch>
</Router>;

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.