【发布时间】:2019-04-04 09:13:36
【问题描述】:
我有一个用 TypeScript 编写的 React 组件,它将 Material-UI 样式应用于 react-select,如下所示。
const styles = (theme: Theme) => createStyles({
});
export interface Props<TI> extends WithStyles<typeof styles, true> {
innerProps: Partial<AsyncSelectProps<TI>>;
selectRef?: React.RefObject<StateManager<TI>>;
onSelectionChange?: (selection: TI | undefined) => void;
}
class MaterialReactSelect<TI> extends React.PureComponent<Props<TI>> {
...
}
export default withStyles(styles, {withTheme: true})(MaterialReactSelect);
我如何修改它,以便将其导出为参数化类型,以便用作
<MaterialReactSelect<string>
selectRef={this.selectRef}
onSelectionChange={this.onSelectionChange}
innerProps={innerProps}
/>
而不是
<MaterialReactSelect
selectRef={this.selectRef}
onSelectionChange={this.onSelectionChange}
innerProps={innerProps}
/>
【问题讨论】:
标签: reactjs typescript material-ui