burkeholland / simple-react-snippets

Simple React Snippets for VS Code that you will actually use
206 stars 84 forks source link

Not working in .tsx? #70

Open glassesUSA opened 2 years ago

glassesUSA commented 2 years ago

For some reason I cannot run any of these scripts in a .tsx file...

glassesUSA commented 2 years ago

Correction - It seems its 'sfc' not working at all

am1006 commented 2 years ago

See #50 for reasons.

I can confirm that fc snippet works for TSX files.

scole954387 commented 2 years ago

@am1006 I'm new to react, so does this mean that sfc is no longer suppose to be used? The documentation for the extension hasn't been updated and sfc still works in js files but doesn't work in tsx. I'm creating a project and have been using sfc in all js files and just copying the code over to tsx files. Thanks

am1006 commented 2 years ago

@am1006 I'm new to react, so does this mean that sfc is no longer suppose to be used? The documentation for the extension hasn't been updated and sfc still works in js files but doesn't work in tsx. I'm creating a project and have been using sfc in all js files and just copying the code over to tsx files. Thanks

Hi, I believe so. The concept of "sfc" is now deprecated after the introduction of react hooks. But I think it's fine for you to copy code to typescript files - it's still compatible.