因此,我最近在Reaction Native中切换到来自Java脚本的TypeScrip,在输入判断useNavigation
钩子时遇到了一个问题.
const nav: typechecking = useNavigation()
和
const nav = useNavigation<typechecking>()
它们都适用于我的代码,但我在想它们之间的区别?
但是,对此的正确解释是什么呢?
Like, what i could think was that because useNavigation()
hook could have many return types, we have restricted he return type to typechecking
in the 2nd one.
While in the 1st one, we are receiving all the types from useNavigation()
hook but are checking nav for typechecking
only.