Skip to content

useHistory in react-router-dom v5 #912

@zhex900

Description

@zhex900

What is your question:

I want to use useHistory hook in my test.

    const {result} = renderHook(() => useHistory(), {
      wrapper: BrowserRouter,
    })

The problem is the result is got giving me the correct route. It seems like the mounted App and the useHistory hook in the test are using two different instances of BrowserRouter

I want to reference useHistory hook inside the test. So I can know the current path and change routes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions