DEV Community

Discussion on: React refactor code #1

Collapse
christianschulze profile image
Christian Schulze

I like the idea of refactoring, but I think step 4 using the object rest/spread operator to pass multiple props is an anti pattern. While prop spreading is convenient and saves typing, what specific props are being passed through? What props is <TextInput> supposed to support? If I needed to refactor <TextInput> using something other than <input> how would I know what props to support?

Collapse
sakethkowtha profile image
sakethk Author

Yes @christianschulze what you said is correct. rest/spread operator only suits for this example. My intention is first it will save typings and next i thought it is more readable. By seeing that snippet once can understand we are using label prop for label and rest of the props for input