Skip to content

Function: applyProps() ​

ts
function applyProps(element, props): void;

Apply prop-getter output to a DOM element, for use without a framework. Call it again after every state change; old listeners are replaced.

Parameters ​

ParameterType
elementHTMLElement
propsElementProps

Returns ​

void

Example ​

ts
const toolbar = createToolbar(editor, { items: basicToolbarItems() })
const render = () => {
  applyProps(root, toolbar.getRootProps())
  for (const item of toolbar.items) applyProps(buttons[item.id], toolbar.getItemProps(item.id))
}
toolbar.subscribe(render)
render()