Reactjs 如何为从库中导入的React组件添加定义
我在React项目中使用Reactjs 如何为从库中导入的React组件添加定义,reactjs,material-ui,flowtype,Reactjs,Material Ui,Flowtype,我在React项目中使用材质ui。我正试图在混合中引入流动 例如: import Paper from 'material-ui/Paper'; type Props = { ruleName: string, rules: Object[], actions: string[], allowSubmit: boolean, onSubmit: ?Function, } const NotifyRule = (props: Props) => ( <Pap
材质ui
。我正试图在混合中引入流动
例如:
import Paper from 'material-ui/Paper';
type Props = {
ruleName: string,
rules: Object[],
actions: string[],
allowSubmit: boolean,
onSubmit: ?Function,
}
const NotifyRule = (props: Props) => (
<Paper style={{ padding: 10, width: '100%' }}>
....
</Paper>
);
这是行不通的。我失败了:
从“物料界面/纸张”导入纸张;
^^^^^^^^^^^^^^^^^^^材料/纸张。未找到所需的模块
解决这个问题的任何指针都会非常有用。您必须单独声明子模块,以使流能够识别它:
declare module 'material-ui/Paper' {
declare var exports: any;
}
declare module 'material-ui' {
// Note: That export value looks weird to me, but whatever
declare var exports: 'material-ui';
}
我们在流类型化的存储库中对redux saga做了类似的事情。。。也许你在那里得到了一些灵感:-)
您是否在.flowconfig中指定了[libs]部分?是的,我相信我的libs是正确的。您能发布更多代码吗?任何与此相关的事情
declare module 'material-ui/Paper' {
declare var exports: any;
}
declare module 'material-ui' {
// Note: That export value looks weird to me, but whatever
declare var exports: 'material-ui';
}