Components:Component Hooks - bettyblocks/cli GitHub Wiki

Contents

Component Hooks provide convenient methods that make it easier to integrate your Components with the Betty Blocks platform.

The following objects are available inside the JSX of a Component:

usePageState

How to use state within your components:

Writing to the state
To write to the state, you have to make use of the usePageState-hook within your component.

This hook acts the same as a useState hook from React, only it read / writes via the Redux state.

const [stateValue, setStateValue] = usePageState('Hello world');

Reading from the state
Once a component makes use of the usePageState-hook, it can be selected from other components in the IDE.

Resolving values
The usePageState hook is also capable of resolving properties, variables & translations.

Note
The usePageState hook does not maintain local state in the context of loops / lists.