Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 1.49 KB

File metadata and controls

61 lines (48 loc) · 1.49 KB

add-exact-prop

Usage

npx react-router-v4-codemods add-exact-prop path/of/files/ or/some**/*glob.js

# or

yarn global add react-router-v4-codemods
react-router-v4-codemods add-exact-prop path/of/files/ or/some**/*glob.js

Local Usage

node ./bin/cli.js add-exact-prop path/of/files/ or/some**/*glob.js

Input / Output


basic

Input (basic.input.js):

import { Router, Route, Switch } from 'react-router-dom';
const MyApp = () => (
  <Router history={history}>
    <Switch>
      <Route path="/posts" component={PostList} />
      <Route path="/posts/:id" component={PostEdit} />
      <Route path="/posts/:id/show" component={PostShow} />
      <Route path="/posts/:id/delete" component={PostDelete} />
    </Switch>
  </Router>
);

Output (basic.output.js):

import { Router, Route, Switch } from 'react-router-dom';
const MyApp = () => (
  <Router history={history}>
    <Switch>
      <Route exact path="/posts" component={PostList} />
      <Route exact path="/posts/:id" component={PostEdit} />
      <Route exact path="/posts/:id/show" component={PostShow} />
      <Route exact path="/posts/:id/delete" component={PostDelete} />
    </Switch>
  </Router>
);