import type { ElvisComponentWrapper } from '@elvia/elvis-component-wrapper'; import { Dispatch, SetStateAction } from 'react'; /** * Create a state that is synced with the webcomponent attribute state, and that triggers events (both in React and webcomponent) on changes. * @param value Initial state of prop. Will also be listened to for changes and update the returned value (without triggering events). * @param propName Name of the prop, used to trigger event on webcomponent. * @param webcomponent * @param reactOnChangeEvent * @returns Tuple similar to `React.useState` with a state and a setter. * @event `${propname}OnChange` event on webcomponent, calls `reactOnChangeEvent`. * @modifies `webcomponent.setAttribute(propName, value)` on change. * * @example * export const Component: FC = ({value, valueOnChange, webcomponent}) => { * const [valueState, setValueState] = useWebComponentState(value, 'value', webcomponent, valueOnChange); * ... * // Will trigger a `valueOnChange` event on webcomponent and call `reactOnChangeEvent`. * return (
setValueState('new value')}>{value}
) * } * * @since 5.2.0 */ export declare const useWebComponentState: (value: T, propName: string, webcomponent: ElvisComponentWrapper | undefined, reactOnChangeEvent: ((newValue: T) => void) | undefined) => [T, Dispatch>];