Skip to content

Component

Anton edited this page Aug 6, 2019 · 10 revisions

Component is a class that allows to implement advanced rendering operations, such as lifecycle methods.

Component: A base class that is usually subclassed to create stateful Preact components.

Name Type & Description
static defaultProps !Object
Properties that will be assigned upon construction of the component.
static getDerivedStateFromProps (props: !Object, state: !Object) => Object
The function to compute the state from properties.
_disable
__x
boolean
Turns off stateful re-rendering.
context* !Object
The context.
props* !Object
The properties.
state* !Object
The state.
setState* (state: !Object, callback?: function(): void) => void
forceUpdate* (callback?: function(): void) => void
render* (props?: !Object, state?: !Object, context?: !Object) => VNode
The render() function is required for all components. It can inspect the props and state of the component, and should return a Preact element or null.
componentWillMount* () => void
Called before the component gets mounted to the DOM.
componentDidMount* () => void
Called after the component gets mounted to the DOM.
componentWillUnmount* () => void
Called prior to removal from the DOM.
getChildContext* () => Object
componentWillReceiveProps* (nextProps?: !Object, nextContext?: !Object) => void
Called before new props get accepted.
shouldComponentUpdate* (nextProps?: !Object, nextState?: !Object, nextContext?: !Object) => boolean
Called before render(). Should return false to skip render.
componentWillUpdate* (nextProps?: !Object, nextState?: !Object, nextContext?: !Object) => void
Called before render().
componentDidUpdate* (prevProps?: !Object, prevState?: !Object, prevContext?: !Object) => void
Called after render().
Clone this wiki locally