4Catalyzer / found

Extensible route-based routing for React applications
https://4catalyzer.github.io/found/
MIT License
794 stars 55 forks source link

Unable to use Redirect as a component #1060

Open steinybot opened 7 months ago

steinybot commented 7 months ago

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 commented 7 months ago

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.