Skip to content

Latest commit

 

History

History

replace-flash-with-toast

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

replace-flash-with-toast

The Flash component has been deprecated in favour of Toast component. This codemod converts all Flash instances to Toast

- import Flash from "carbon-react/lib/components/flash";
+ import Toast from "carbon-react/lib/components/toast";

- <Flash message="hello" />
+ <Toast variant="success" isCenter>hello</Toast>

It's likely that props might be assigned in a different manners, therefore this codemod accounts for several prop patterns.

<Flash prop="something" />
<Flash prop={"something"} />
const value = "something";

<Flash prop={value} />;
const props = { prop: "something" };

<Flash {...props} />;
<Flash {...{ prop: "something" }} />
const prop = "something";

<Flash {...{ prop }} />;
const value = "something";

<Flash {...{ prop: value }} />;

If there is a pattern that you use that is not transformed, please file a feature request.

Usage

npx carbon-codemod replace-flash-with-toast <target>

Example

npx carbon-codemod replace-prop-value src