Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race conditions while using react-router-6 adapter #286

Open
shughes-uk opened this issue Feb 6, 2024 · 3 comments
Open

Race conditions while using react-router-6 adapter #286

shughes-uk opened this issue Feb 6, 2024 · 3 comments

Comments

@shughes-uk
Copy link

I've been noticing race conditions with the react-router-6 adapter that don't seem to occur when just using the window adapter.

Specifically this seems to happen in situations where a navigate occurs below a component that is setting a query param.

const someComponent = () => {
    const [useQueryParam, setUseQueryParam] = useQueryParam(false);
    useEffect(() => {
        setUseQueryParam(true,"replaceIn");
    }
    return (
        <Navigate to= "/someRoute" replace  />
    )
}

This results in the url just having the query param, and not navigating to /someRoute. It works fine if you don't use replace. I have experimental batching turned on.

@shughes-uk
Copy link
Author

Worth noting they don't seem to happen if i use the window history adapter, but i'm also not sure what the consequences of doing that are if i'm using react routing?

@shughes-uk
Copy link
Author

My use case is persisting some global internal state to the url so users can easily share their views. As they navigate around the url is wiped, i'm using effects to restore the internal state to the url.

@shughes-uk
Copy link
Author

This seems to have gone away when I switched to using createBrowserRouter vs the older <BrowserRouter style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant