Created
July 21, 2018 04:07
-
-
Save cottom/b1f5cd46d80296d09e1578835493361f to your computer and use it in GitHub Desktop.
react tips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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