Skip to content

Instantly share code, notes, and snippets.

@cottom
Created July 21, 2018 04:07
Show Gist options
  • Save cottom/b1f5cd46d80296d09e1578835493361f to your computer and use it in GitHub Desktop.
Save cottom/b1f5cd46d80296d09e1578835493361f to your computer and use it in GitHub Desktop.
react tips
import PropTypes from 'prop-types';
export const contextTypes = {
renderText: PropTypes.func,
form: PropTypes.any,
model: PropTypes.any,
mode: PropTypes.string,
schemas: PropTypes.any,
};
export interface IContext {
model?: any;
renderText: (string) => string;
form: WrappedFormUtils;
mode: string;
schemas: ISchemaItem[];
}
class Container extends React.Component<IProps, IState> {
constructor(props: IProps, context: IContext) {
super(props, context);
this.state = {};
}
static childContextTypes = contextTypes;
getChildContext() {
return this.getChildCommonProps();
}
getChildCommonProps() {
// TODO
}
}
export default class EndPoint extends React.PureComponent<IProps, IState> {
context: IContext;
static contextTypes = contextTypes;
constructor(props: IProps, context: IContext) {
super(props, context);
this.state = {};
}
componentDidMount() {
//this.context.xxx
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment