This recipe provides a collection of codemods to help you migrate your codebase to Preact X. These codemods are designed to streamline the transition process by automating common code transformations.
Codemods Included
The following codemods are included in this recipe:
-
Replace
this.state
withprevState
Converts instances ofthis.state
to useprevState
to align with Preact X best practices. -
Convert
props.children
tochildArray
Transformsprops.children
into a child array, which is the recommended structure in Preact X. -
Update Preact Import Source
Updates import paths to the new Preact X syntax, ensuring that your imports align with the latest version. -
Convert Default Import to Namespace Import
Replaces default imports with namespace imports (import * as Preact from 'preact';
) to prevent potential issues and improve compatibility with Preact X.
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community