Entity class methods

Aside from willMount() and create(), each method will be passed a params object of the following type:

{
   previousProps<Object>,
   previousChildren<Array>,
   previousState<Object>,
   previousContext<Object>,
   props<Object>,
   children<Array>,
   context<Object>,
   state<Object>,
   setState<Function>,
   getParams<Function>
}

Comparison to React methods

Many, but not all, of the Entity class methods correspond to a React class method

Declarity Method React Method
willMount componentWillMount
create no equivalent
didCreate no equivalent
didMount componentDidMount
shouldUpdate componentShouldUpdate
willUpdate componentWillUpdate
update no equivalent
render render
didUpdate componentDidUpdate
willUnmount componentWillUnmount
didUnmount no equivalent
getChildContext getChildContext

willMount()

Called before the entity is mounted, and before the create() method is called.

create()

type createOptions = {
  props,
  children,
  context,
  setState<Function>,
  getParams<Function>
}

function create = (options<createOptions>) => state<Object>

The create() method is where you will create/instantiate whatever state that belongs to the entity. The method accepts a return value of type <Object> that will set as the entity's state.

didCreate()

Called after create() has been called, but before render() is called for the first time.

didMount()

Called after render() is called the first time.

shouldUpdate()

Called before a component updates. Accepts a return value of type <Boolean>. If return value is true, component's update related methods will be called. If false, then will not.

Note: If component does not update, then neither will its child entities.

willUpdate()

Called before update() and render() is called. Accepts a return value of type <Object> that is updated state. This updated state will be shallow merged into the current state.

update()

Called when a component is updated. This is just before render() is called.

didUpdate()

Called after a component is updated, and render() has been called.

willUnmount()

called Before any entities created within render() are unmounted.

didUnmount()

called After any entities created within render() are unmounted.

getChildContext()

Used to set context on child entities.

results matching ""

    No results matching ""