尝试将其作为道具传递给应用组件时收到错误"类型 '{ theme: Theme; }' 无法分配给类型"



就应用程序启动而言,我采取了一种稍微不同的方法,因为我想在App组件中使用useLocation挂钩。我对打字有点陌生,遇到了一个问题。这是我的:

// index.tsx
const theme: Theme = createMuiTheme({
palette: {
primary: {
main: '#43C099',
},
},
});
ReactDOM.render(
<Provider store={store}>
<ThemeProvider theme={theme}>
<CssBaseline />
<Router>
<App theme={theme} />
</Router>
</ThemeProvider>
</Provider>
, document.getElementById('root'));
// App.tsx
interface IFC extends FC {
theme: Theme
}
const App: FC<IFC> = ({ theme }) => {
// ...

错误来自index.tsx,IDE在<App ...下加下划线并抛出错误

Type '{ theme: Theme; }' is not assignable to type 'IFC'.

我在这里做错了什么?

想明白了。应该是

interface IFC {
theme: Theme
}

相关内容

最新更新