React/Render To Readable Stream

/icons/calendar.svg

Last update

Aug 13, 2024

Refactor renderToReadableStream call expressions to use a combined object argument

This codemod simplifies the argument structure for renderToReadableStream, aligning it with new conventions or improving readability and maintainability.

  • Finds Call Expressions: Identifies calls to renderToReadableStream in the code.

  • Argument Check: Ensures the function calls have exactly three arguments, with the second and third being identifiers.

  • Create Object Argument: Combines the second and third arguments into a new object argument with properties onError, context, and a default identifierPrefix.

  • Replace Arguments: Updates the function call to use the new object argument.

Before

renderToReadableStream(widget, onErrorCallback, appContextData);

After

renderToReadableStream(widget, {
onError: onErrorCallback,
context: appContextData,
identifierPrefix: prefix,
});

Build custom codemods

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

background illustrationGet Started Now