Components
基于 material-ui
、formik
、react-dnd
等流行组件库的封装。
Best practice
Component with styles
import { createStyles, Theme, withStyles } from '@material-ui/core';import React from 'react';export interface MyAwesomeProps {children: ReactElement | ReactElement[];classes?: {root?: string;...};...}const styles = (theme: Theme) =>createStyles({root: {width: (props: MyAwesomeProps) => props.xxx ? 123 : 456,...},...});// name starts with `Mui` to make class names deterministicexport const MyAwesome = withStyles(styles, { name: 'MuiIdeMyAwesome' })(({children,classes,...,...props}: MyAwesomeProps) => {// bla bla blareturn (<div className={classes.root} {...props}>...</div>);},);