React-router
migration
byalexbit-codemod

React Router/4/Replace Location Query

/icons/calendar.svg

Last update

Jul 24, 2024

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