React Router/4/Replace Location Query

1.0.1Last update Jul 24, 2024
by@alexbit-codemod
React-router
migration

This codemod replaces instances of location.query with parse(location.search), where parse is a function imported from query-string.

Before

const List = ({ location }) => (
<div>
<h1>{location.query.sort}</h1>
</div>
);

After

import { parse } from 'query-string';
const List = ({ location }) => (
<div>
<h1>{parse(location.search).sort}</h1>
</div>
);

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now