从 react-router-dom 升级到 useParams () 中使用的版本 4 后,出现 typeScript 错误
"typescript": "^4.0.2"
import { useParams } from 'react-router-dom';
const { sumParams } = useParams();
Run Code Online (Sandbox Code Playgroud)
Property 'sumParams' does not exist on type '{}'.
Run Code Online (Sandbox Code Playgroud)
该项目运行良好,只有在升级后才会引发错误
使用反应导航时存在类型问题,当使用Stack.Navigation或Stack.Group来自createNativeStackNavigator
该问题表示JSX.element消息末尾的类型不匹配更具体: Type '{}' is not assignable to type 'ReactNode'
整个消息:
'Stack.Navigator' cannot be used as a JSX component.
Its element type 'ReactElement<any, any> | Component<Omit<DefaultRouterOptions<string> & { id?: string | undefined; children: ReactNode; screenListeners?: Partial<...> | ... 1 more ... | undefined; screenOptions?: NativeStackNavigationOptions | ... 1 more ... | undefined; defaultScreenOptions?: NativeStackNavigationOptions | ... 1 mo...' is not a valid JSX element.
Type 'Component<Omit<DefaultRouterOptions<string> & { id?: string | undefined; children: …Run Code Online (Sandbox Code Playgroud) typescript react-native react-navigation expo react-navigation-v6
我正在开发 expo SDK 版本:36 和所有平台 (ios/android/web)
当react-navigation按照文档中的描述第一次安装并运行 jest --watch 时,出现以下警告:
console.warn node_modules/react-native/Libraries/YellowBox/YellowBox.js:71
Animated: `useNativeDriver` is not supported because the native animated module is missing. Falling back to JS-based animation. To resolve this, add `RCTAnimation` module to this app, or remove `useNativeDriver`. More info: https://github.com/facebook/react-native/issues/11094#issuecomment-263240420
Run Code Online (Sandbox Code Playgroud)
它也发生在浏览器控制台中:
bundle.js:18272 Animated: `useNativeDriver` is not supported because the native animated module is missing. Falling back to JS-based animation. To resolve this, add `RCTAnimation` module to this app, or remove `useNativeDriver`. More …Run Code Online (Sandbox Code Playgroud) 我是 redux 的新手。我正在将 redux 与 react-native 结合使用。我刚刚创建了一个简单的应用程序,它在 redux 上存储了 RGB 颜色,并且我正在使用和更新组件的状态。输出很好,但我的 cmd 窗口出现错误。我正在使用 Expo-CLI。 在此处输入图片说明
我的应用程序代码在这里 App.js
import React from 'react';
import { View } from 'react-native';
import reducer from './src/reducers/Index'
import {Provider} from 'react-redux'
import {createStore} from 'redux'
import ColorTile from './src/component/ColorTile.js'
const store=createStore(reducer)
export default function App() {
return (
<Provider store={store}>
<View style={{flex:1,justifyContent:"center",alignItems:'center'}}>
<ColorTile />
</View>
</Provider>
);
}
Run Code Online (Sandbox Code Playgroud)
Index.js 代码
import {combineReducers} from 'redux'
import rgbReducer from './rgbReducer'
const allReducer=combineReducers({
rgb:rgbReducer
})
export default allReducer
export …Run Code Online (Sandbox Code Playgroud) reactjs ×5
react-native ×4
javascript ×3
expo ×2
typescript ×2
css ×1
jestjs ×1
material-ui ×1
react-dom ×1
react-redux ×1