Skip to main content

Contract

contract means a public convention for changes to a stillness-component that will provide various information about the particular stillness-component. It responds to stillness state changes by updating the props of the wrapper component.

collect

For each component that needs to listen to the stillness state, a pure function can be customized and passed to connectStillness or useStillness. The stillness-component will collect and call this function when the stillness state is modified and merge the return value into props.

The example is as follows:

Hoc
const spec = {
collect: (props,contract) => ({
isStillness: contract.isStillness()
stillnessId: contract.getStillnessId()
});
};

connectStillness(spec);

or

Hooks
const spec = (props) => {
return {
collect: (contract) => ({
isStillness: contract.isStillness()
stillnessId: contract.getStillnessId()
})
}
}

function Count(props) {
const collected = useStillness(spec(props));
...
}