我使用 react-navigation 进行 react-native。是否有一个选项可以让非活动选项卡屏幕像 unmountInactiveRoutes: true 那样在 DrawerNavigator 中卸载?我找不到像BottomTabNavigator的unmountInactiveRoutes这样的东西。
我在 BottomTabNavigator 中有两个 stacknavigator,我想自动卸载它们。
这是错误的示例:
interface Block {
id: string;
}
interface TitleBlock extends Block {
data: {
text: "hi",
icon: "hi-icon"
}
}
interface SubtitleBlock extends Block {
data: {
text: "goodbye",
}
}
interface CommentBlock extends Block {
author: string;
}
type BlockTypes = TitleBlock | SubtitleBlock | CommentBlock
function mapper(block : BlockTypes) {
if(block?.data?.text){ // TS Error here!!!
/** do something */
}
}
Run Code Online (Sandbox Code Playgroud)
当块具有特定属性时,我想在函数中执行某些操作,但 TS 不允许我这样做,即使 BlockType 中存在具有该属性的类型。
管理此类功能的最佳方法是什么?
在测试库文档的某些页面上出现了使用 screen.getByText 的示例:
expect(screen.getByText(/you are home/i)).toBeInTheDocument()
Run Code Online (Sandbox Code Playgroud)
我的问题是这与此有何不同:
screen.getByText(/you are home/i)
Run Code Online (Sandbox Code Playgroud)
为什么当 screen.getByText 执行相同操作时文档使用 .toBeInTheDocument() (当“you are home”文本不在文档中时抛出错误)?这不是多余的吗?