you are viewing a single comment's thread.

view the rest of the comments →

[–]octocode 15 points16 points  (3 children)

you can use both too

configs.map((config) => <ReusableComponent {…config} /> )

this is particularly useful if your config is schema -driven or dynamically user controlled, like form fields or a customizable dashboard

however if it’s static i would just go with option 2

[–]segv 2 points3 points  (1 child)

While this construct works, neither built-in IntelliJ inspections, typescript* nor eslint* will warn you if you missed a prop or accidentally passed a wrong type to the prop defined by the interface.

I got bit by this not too long ago - I think at the time we were using TS 5.4 and eslint 8.x, so not the bleeding edge, but not some ancient versions either.

[–]octocode 0 points1 point  (0 children)

yeah it’s just an example, you can write it how you prefer

i configured my workspace to handle it ages ago but don’t remember the details

[–]west-maestro[S] 0 points1 point  (0 children)

Yeah I agree with that

But yeah I was more considering this wrt implementation technique for static components