I cannot get <CompatRoute> to work #9373
-
I've seen similar questions which seem to be unanswered. After installing import { Route, Router, Switch } from 'react-router-dom';
import { CompatRoute, CompatRouter } from 'react-router-dom-v5-compat';
<Router history={history}>
<CompatRouter>
<Switch>
{/* This one works */}
<Route exact path="/:lang/about" component={About} />
{/* This one does not */}
<CompatRoute
exact
path="/:lang/:application(firefox|android)/addon/:slug/privacy/"
render={() => <AddonInfo infoType={ADDON_INFO_TYPE_PRIVACY_POLICY} />}
/>
{/* Nor does this - with different syntax */}
<CompatRoute
exact
path="/:lang/:application(firefox|android)/addon/:slug/eula/"
children={<AddonInfo infoType={ADDON_INFO_TYPE_EULA} />}
/>
{/* Nor does this - with different syntax */}
<CompatRoute
exact
path="/:lang/:application(firefox|android)/addon/:slug/license/">
<AddonInfo infoType={ADDON_INFO_TYPE_CUSTOM_LICENSE} />
</CompatRoute>
</Switch>
</CompatRouter>
</Router> I have seen a number of different syntaxes propsed for the component that renders the route, and none of the above seem to work for me. The component in question, Does anyone have any suggestions about something else I might try? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I agree the docs lead to quite some confusion. I see you have exhausted several different attempts, have you tried the following? (I also don't know if this will work, but it's worth a try if you haven't tried it yet) <CompatRoute
exact
path="/:lang/:application(firefox|android)/addon/:slug/privacy/"
component={AddonInfo}
/> |
Beta Was this translation helpful? Give feedback.
-
For anyone following along at home, the problem was the regex in the |
Beta Was this translation helpful? Give feedback.
For anyone following along at home, the problem was the regex in the
path
. I hadn't come across the information that regex in paths was no longer allowed inv6
, but after removing the regex things started working.