'New fearture in react-router-dom v6 useOutletContext() issue, what versions support it

I use react-router-dom and react-router v6.0.2 and I want to use the useOutletContext() the new features in v6 to pass props through outlet but it return this issue.

enter image description here

How can't I fix it and what versions does useOutletContext() support



Solution 1:[1]

The useOutletContext hook and Outlet context was a feature introduced in v6.1.0.

<Outlet> can now receive a context prop. This value is passed to child routes and is accessible via the new useOutletContext hook.

Uninstall the current version

npm uninstall -s react-router-dom

Either bump to this minimum version

npm install -s [email protected]

or install the current/latest version

  • npm install -s react-router-dom@6
    
  • npm install -s react-router-dom@latest
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1