私はリアクションルータdom v4を使用してプライベートルート内に2つのコンポーネントをレンダリングしようとしています。これは通常のルートを使用して可能ですが、カスタムルートを使用する場合はそうではありません。 "React.createElement:型が無効です - 文字列(組み込みコンポーネント用)またはクラス/関数(複合コンポーネント用)がありますが、未定義です。それはで定義されています、またはあなたがデフォルトと名前の輸入を混同している可能性があるファイルからコンポーネント。 」反応ルータdomのレンダリングとプライベートルートの使用
カスタムルート(認証)return (
<Route
{...rest}
render={props =>
this.currentUser()
? <Component currentUser={this.currentUser} {...props} />
: <Redirect
to={{
pathname: '/auth/login',
state: { from: props.location }
}}
/>
}
/>
)
はその後、私のルートでは、私はこの
return (
<div>
<Switch location={isModal ? this.prevLocation : location}>
<Authenticated path="/" exact component={Main} />
<Route path="/auth/register" exact component={Register} />
<Route path="/auth/login" exact component={Login} />
<Authenticated
path="/clients/:id/edit"
render={(props) => (// Not working as expected. Works fine using Route instead of Authenticated
<div>
<Main />
<ClientEdit />
</div>
)}
/>
</Switch>
{isModal ?
<Authenticated
path='/clients/new'
component={ClientNew}
/>
: null}
{isModal ?
<Authenticated
path='/clients/:id/edit'
component={ClientEdit}
/>
: null}
</div>
);
Haventは、そのようなコンポーネントを使うことができることを理解しました – adavia
'component' propで渡しているものは、実際には匿名の反応コンポーネントです。 –