Dec
6
1 day ago
Activity icon
issue

timdorr issue comment remix-run/react-router

timdorr
timdorr

[Bug]: Scroll Restoration when re-opening the Browser

What version of React Router are you using?

latest?

Steps to Reproduce

  1. Use a chromium based Browser with setting 'Continue where I left off'
  2. Open https://remix.run/docs/en/v1/api/remix#cookie-api
  3. Close the Browser
  4. Open the Browser

(Verified in Win11, Brave and Chrome)

Expected Behavior

Expected to be at Cookie-Api Section

Actual Behavior

Top of the page.

timdorr
timdorr

React Router itself doesn't provide any kind of scroll restoration.

Activity icon
issue

timdorr issue remix-run/react-router

timdorr
timdorr

Is router-keepalive supported? I am from China

What version of React Router are you using?

Is router-keepalive supported? I am from China

Steps to Reproduce

Is router-keepalive supported? I am from China

Expected Behavior

Is router-keepalive supported? I am from China

Actual Behavior

Is router-keepalive supported? I am from China

Activity icon
issue

timdorr issue comment remix-run/react-router

timdorr
timdorr

Is router-keepalive supported? I am from China

What version of React Router are you using?

Is router-keepalive supported? I am from China

Steps to Reproduce

Is router-keepalive supported? I am from China

Expected Behavior

Is router-keepalive supported? I am from China

Actual Behavior

Is router-keepalive supported? I am from China

timdorr
timdorr

Please don't open issues not related to the React Router library itself.

Activity icon
issue

queengooborg issue comment remix-run/react-router

queengooborg
queengooborg

allow more regex for paths instead of the defaults [Feature]:

What is the new or updated feature that you are suggesting?

update current route.path to allow more conditional regex paths for multiple conditions like in v5.

v5 route: /(wines|whiskeys|sakes|beers)/:id/:productName?

Why should this feature be included?

current v6 doesnt include this anymore. only allow strict routes.

queengooborg
queengooborg

+1 for getting this functionality added back in. Just like optional routing parameters, this was such a useful (and critical feature), and it's not clear why this functionality was removed...we're gonna have to stay on v5 because of it. I'd love to hear a reasoning from the package maintainers as to what led to this surprising and large change.

started
started time in 3 hours ago
Activity icon
issue

dezoito issue comment remix-run/react-router

dezoito
dezoito

useParams returns an empty object in unit tests

I have noticed that in unit tests, useParams hook always returns an empty object. Here is my unit test:

test('renders learn react link', () => {
  render(
    <MemoryRouter initialEntries={['/person/2']}>
      <Person />
    </MemoryRouter>
  );
  const labelElement = screen.getByText(/Person id: 2/i);
  expect(labelElement).toBeInTheDocument();
});

As you can see, in my test I have set the initial route to '/person/2'.

If you run the repro project below:

yarn
yarn dev

and go to this address: http://localhost:3000/person/2, you should see the label: "Person id: 2". Thus, when the app is running useParams works fine. But in unit tests it always returns an empty object.

Version

5.2.0

Test Case

Here is the repro project: react-router-repro.zip

Steps to reproduce

  1. Run tests
yarn
yarn test
  1. Test is failing because useParams returned an empty object: Screenshot 2021-04-07 at 14 14 35

Expected Behavior

useParams() hook in unit tests should return url params.

Actual Behavior

useParams() hook in unit tests returns an empty object.

dezoito
dezoito

@Mikilll94 , were you able to get your tests running?

I am having similar issues, even though my tests have a <Route> defined

Activity icon
issue

queengooborg issue comment remix-run/react-router

queengooborg
queengooborg

V6: Optional parameters

I tried adding a trailing ? to a route using the v6 router, but it didn't seem to work.

<Route path='/page/:friendlyName/:sort?' element={<Page/>} />

Are optional parameters supported in v6, or are they coming later?

queengooborg
queengooborg

I'm a bit surprised to see that support for optional parameters was dropped in v6. This is an extremely useful feature, and its removal has made a v5 to v6 project more challenging. The workarounds people here have suggested are great for smaller apps, but it's not clear why there has to be a workaround in the first place?

I'd love to hear the reasoning behind this change.

started
started time in 4 hours ago
Activity icon
issue

johnhillphoto issue comment remix-run/react-router

johnhillphoto
johnhillphoto

[Bug]: [ProxyFacade] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment]

What version of React Router are you using?

6

Steps to Reproduce

Code usage snippet below: image

Expected Behavior

Seeing that all of the children of the < Routes > component are < Route >s, it should be working correctly and not raising an error.

Actual Behavior

Fails to work, saying that children should all be < Route >s when they already are.

johnhillphoto
johnhillphoto

Would it be possible to add some kind of configuration option to disable this invariant error? Our app works perfectly in production, but we cannot use react-hot-loader now. Our app worked well with v6.0.0 also.