Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>react replace/refactor componentNew to Visual Studio Code? Get it now.
react replace/refactor component

react replace/refactor component

rumemeta-maila

|
217 installs
| (1) | Free
to easily replace/refactor your react component to another
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

refactor your react component easily

suppose u have original:

<Comp a="1"><Child b="2"><SecondChild c="3"> </SecondChild></Child></Comp>

comp:

<MyComp abc="1"><X>yolo!</X></MyComp>

use this properties:

meh=3b anyprop=4c yo=0a  a=- children=1 b={(v)=>false} 

u will get result:

<MyComp meh="2" anyprop="3" yo="1" b={(v)=>false}><X>yolo!</X></MyComp>

🔸 commands

rpc: setup

open new file to setup what to replace

rpc: find

find component to replace

rpc: replace

to replace component

🔸 settings

separated with @@@ for each items

eg. src=mysrc@@@test=className="x

key item
src a source folder which to search the component to replace
test for additional regex test which compoenent to replace. note: use '\' for every non word char

🔸 exclude

file to be excluded from search eg f=test.jsx

key item
f file name to be excluded

🔸 comp

component to be replaced with

eg. <Comp someprop="xyz"></Comp>

🔸 comp-to-replace

component to be replaced

eg. <Comp someprop="xyz"></Comp>

🔸 default

a default property |key| item | |--|--| | property-choices | property default. whose component property to use for replaced compoent? 0 for original, 1 for comp, 2 for component-to-rep lace

🔸 properties

property list that will be included in the replaced component.

there also speacial property 'children'.

if property in original component not included there that property will follow rule default: property-choices.

special selector:

  • 0 = original
  • 1 = comp
  • 2 = comp-to-replace
  • 3-to n = number of children= is for property inside original component's children
  • -= to remove property

function:

  • :quot: quote around property

refer to other property suppose u have original:

<Comp a="1"><Child b="2"><SecondChild c="3">its second child</SecondChild></Child></Comp> comp:

<MyComp abc="1"><X>yolo!</X></MyComp>

properties: meh=3b //select Child's property:b anyprop=4c //select SecondChild's property:c yo=0a //select Original's property:a a=- //remove a from component b={(v)=>false} //add new property children=1 //use comp's children property hola=4:quot:children

u will get result:

<MyComp meh="2" anyprop="3" yo="1" b={(v)=>false} hola="its second child<"> <X>yolo!</X></MyComp>

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft