由于 RoutingContext,PropType 验证抛出错误
PropType validation is throwing an error because of RoutingContext
我正在验证的所有道具都收到以下错误:
警告:propType 失败:未在 AssetManagementShow
中指定必需的道具 assetType
。检查 RoutingContext
.
的渲染方法
警告:propType 失败:未在 AssetManagementTransactionsFecher
中指定必需的道具 assetTypes
。检查 RoutingContext
的渲染方法。
我的路线如下所示:
<Route path='asset_management' component={AssetManagementContainer} >
<IndexRoute component={AssetManagementIndex} />
<Route path=':name' component={AssetManagementTransactionsFetcher}>
<IndexRoute component={AssetManagementShow} />
<Route path=':transactionKey' component={TransactionsShow} />
</Route>
</Route>
我在尝试呈现 AssetManagementShow(和 TransactionsShow)时遇到此错误。我从 AssetManagementTransactionsFetcher 和 AssetManagementShow 的道具中收到错误。
AssetManagementContainer 仅获取数据并使用 React.cloneElement 呈现子路由。 AssetManagementTransactionsFetcher 做同样的事情 - 它获取数据并使用新道具呈现子路由。
我想这就是问题所在。当我使用 React.cloneElement 将道具传递给子路由时,子路由未正确验证其 PropTypes。
我是 运行 react-router v1.0.3
这正是 prop 类型验证与 cloneElement
一起工作的方式——验证是在元素创建时完成的,而不是在挂载时完成的。
此处提供更多详细信息和参考:https://github.com/rackt/react-router/blob/master/upgrade-guides/v1.0.0.md#routehandler。
我正在验证的所有道具都收到以下错误:
警告:propType 失败:未在 AssetManagementShow
中指定必需的道具 assetType
。检查 RoutingContext
.
警告:propType 失败:未在 AssetManagementTransactionsFecher
中指定必需的道具 assetTypes
。检查 RoutingContext
的渲染方法。
我的路线如下所示:
<Route path='asset_management' component={AssetManagementContainer} >
<IndexRoute component={AssetManagementIndex} />
<Route path=':name' component={AssetManagementTransactionsFetcher}>
<IndexRoute component={AssetManagementShow} />
<Route path=':transactionKey' component={TransactionsShow} />
</Route>
</Route>
我在尝试呈现 AssetManagementShow(和 TransactionsShow)时遇到此错误。我从 AssetManagementTransactionsFetcher 和 AssetManagementShow 的道具中收到错误。
AssetManagementContainer 仅获取数据并使用 React.cloneElement 呈现子路由。 AssetManagementTransactionsFetcher 做同样的事情 - 它获取数据并使用新道具呈现子路由。
我想这就是问题所在。当我使用 React.cloneElement 将道具传递给子路由时,子路由未正确验证其 PropTypes。
我是 运行 react-router v1.0.3
这正是 prop 类型验证与 cloneElement
一起工作的方式——验证是在元素创建时完成的,而不是在挂载时完成的。
此处提供更多详细信息和参考:https://github.com/rackt/react-router/blob/master/upgrade-guides/v1.0.0.md#routehandler。