Search code examples
reactjsreact-router-dompushbrowser-history

How to implement history property and past it to Router... inside the index.tsx


I need help. How to implement history property to use it as a global prop and also in hole project(also in file with .ts extensions).

I need (history.push method) inside .ts (not functional components .tsx) file to redirect to the home page.

you can see images and the problem whit the history prop when I tried to pass inside Router. enter image description here

enter image description here


Solution

  • enter image description here

    You've the latest version of history installed but you've the previous version of react-router-dom. react-router-dom@5 uses history@4.

    1. Uninstall the current version: npm un -s history
    2. Install the older version: npm i -s history@4