Event Handling On Change

1.0.0Last update Dec 8, 2024
by@krishn404

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