Generic type arguments in JSX elements with withStyles

后端 未结 4 1837
别跟我提以往
别跟我提以往 2021-01-13 12:05

In React with material-ui I am trying to create a JSX component that accepts generic parameters and also uses the withStyles HOC to inject my styles.

Th

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-13 12:31

    This works enough for me using Visual Studio:

    import React from "react";
    import { withStyles, WithStyles } from "@material-ui/styles";
    
    const styles = {
      root: { ... },
    };
    
    export interface Props { ... }
    export interface State { ... }
    
    export class TableComponent extends React.PureComponent & WithStyles, State> {
      render () {
        return 
    ; } } export const Table = (withStyles(styles)(TableComponent) as any) as new () => TableComponent; export default Table;

提交回复
热议问题