类型{someParam:boolean}的参数无法分配给类型的参数' partial< string |布尔值>'
当我尝试使用当前生成的类型向导航器屏幕添加一些参数时,我会在标题上提到的错误 请注意,它在其他屏幕上工作,并且在此时,我可以在键入route.params
// Screen is an object of screens name
type RouteType<T extends Object, S extends Screen> = RouteProp<
{
[key in S]: T;
},
S
>;
export type NavigationInjectedProps<T extends Object, S extends Screen> = {
navigation: NavigationProp<T>;
route: RouteType<T, S>;
};
方法的道具
type Props = NavigationInjectedProps<
params,
'ExampleComp'
>;
添加到我的组件参数
interface params {
someParam: boolean;
someOtherParam: string;
}
时访问它,以设置显示错误显示的参数
export default ExampleComp ({navigation}:Props) {
useEffect(() => {
navigation.setParams({ someParam : false }); // got error here
}, [navigation]);
}
...
。
I m gotting the error mentioned on the title while I m trying to add some params to the navigator screen using the current generated type
note that it's working on other screens and also on this I can access to it when typing route.params
// Screen is an object of screens name
type RouteType<T extends Object, S extends Screen> = RouteProp<
{
[key in S]: T;
},
S
>;
export type NavigationInjectedProps<T extends Object, S extends Screen> = {
navigation: NavigationProp<T>;
route: RouteType<T, S>;
};
the props added to my component
type Props = NavigationInjectedProps<
params,
'ExampleComp'
>;
params
interface params {
someParam: boolean;
someOtherParam: string;
}
method to set the param where the error is shown
export default ExampleComp ({navigation}:Props) {
useEffect(() => {
navigation.setParams({ someParam : false }); // got error here
}, [navigation]);
}
...
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论