React-router V4 - Replace params prop

verified codemod icon

Replaces params prop passed by react-router with match.params.

React Router
jscodeshift
Estimated time saving
~1 minutes/occurrence
Change mode
Assistive
Applicability criteria

React Router version 3.x.y

Made by
Codemod.com
Codemod.com

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod react-router/4/replace-param-prop
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Description

Replaces params prop passed by react-router with match.params.

Before

const PostEdit = ({ params }) => (
	<div>
		<h1>Post {params.id}</h1>
	</div>
);

After

const PostEdit = ({ match }) => (
	<div>
		<h1>Post {match.params.id}</h1>
	</div>
);