Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Passing state by history.push({..}) in TypeScript

I used history.push to redirect to my desired url and passed an information via the included state to the next route like this:

const history = useHistory()
history.push({
   pathname: '/someurl/',
   state: {
      foo: bar
   }
})

and in JavaScript this worked absolutely as expected. Now I am migrating this file to TypeScript and I am getting the following error:

Argument of type '{ pathname: string; state: { foo: bar; }; }'
is not assignable to parameter of type 'To'.

Object literal may only specify known properties, and
'state' does not exist in type 'PartialPath'

For some reason he thinks that I only pass a pathname without a state right? Does anyone know how to fix that?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Same issue resolved by after trying to fix it I found the problem appears when using custom history, like import history from 'history'; and then <Router history={history}>...</Router> So when I replaced it with <BrowserRouter>...</BrowserRouter> the problem disappeared.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!