Event Handling On Change

/icons/calendar.svg

Last update

Dec 8, 2024

This codemod automates the update of your onChange event handler function to support the new Descendant[] type and selection handling introduced in version 0.104.

Before (v0.88):

const onChange = value => {
setValue(value);
};

After (v0.104)

const onChange = (newValue: Descendant[]) => {
setValue(newValue);
// Additional state management if needed
const selection = editor.selection;
if (selection) {
// Handle selection changes
}
};

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now