Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
migration
byalexbit-codemod
React Router/4/Replace Location Query
Last update
Jan 10, 2025
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