3

In SPFx No JavaScript Framework webpart contain "webpart.ts" file and write code in it.

But in React SPFx webpart, there are 2 file :

1) webpart.ts file
2) webpart.tsx file in component folder.

Can any buddy explain what can we do with webpart.ts file and webpart.tsx file ?

Thanks.

  • Do you require any further details from my answer? – James Randal Jan 15 at 2:51
  • Do you think my answer below is sufficient to be marked as such, or would you like further details. – James Randal yesterday
6

TSX allows for embedding JSX elements inside the file, and is largely used by React.

TS files are plain old Typescript files and do not support adding JSX Elements.

Typically you would seperate concerns by placing only code relating to presentation in the TSX files.

The following link is useful for understanding some of the key differences

https://stackoverflow.com/questions/34224007/is-there-any-downside-to-using-tsx-instead-of-ts-all-the-times-in-typescript

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.