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

Unable to use Redirect as a component #1060

Open
steinybot opened this issue Feb 6, 2024 · 1 comment
Open

Unable to use Redirect as a component #1060

steinybot opened this issue Feb 6, 2024 · 1 comment

Comments

@steinybot
Copy link

steinybot commented Feb 6, 2024

It is a little hard for me to nail down exactly what the problem is since I am using Scala.js with ScalablyTyped bindings for found but this is what I am seeing:

Screenshot 2024-02-07 at 10 41 42 AM

It seems that React thinks that the Redirect component is a class component and is calling render with no arguments.

There are some pretty suspicious comments on Redirect.tsx about it trying to trick the consumer into thinking it is a React.Component which seem relevant.

@steinybot
Copy link
Author

Ah I managed to reproduce it without Scala.js.

Here is what does not work:

        {
          path: 'baz2',
          Component: () => <Redirect to='/foo'/>
        }

The way it gets used in the example of:

        new Redirect({
          from: 'baz',
          to: '/foo',
        }),

is pretty strange IMO. I much prefer to stick to the route object way of configuring it.

@steinybot steinybot changed the title Redirect being a fake class component causes problems Unable to use Redirect as a component Feb 7, 2024
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