Sp-dev-docs: Cant have html elements in react component render method

Created on 24 May 2017  路  8Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [ X] Bug

Expected or Desired Behavior

Abiliy to create react dropdown react component like in the guild
c

Observed Behavior

The project just say Cannot find name 'div'. or any html element in a react component render method

Steps to Reproduce

https://dev.office.com/sharepoint/docs/spfx/web-parts/guidance/build-custom-property-pane-controls

Most helpful comment

are you developing it in ts file or tsx file?

All 8 comments

Interesting part is if you put the react component into the file that contain the component for the webpart that was generated from yoman, typescript does not throw error on render method.

are you developing it in ts file or tsx file?

everything is in .ts files just like the guild talks about

Firstly if you need to render react element using the xml syntax you then must use tsx file. You must also wrap the whole elements in a container

if you need to render multiple elements within render.

So why do the other files dont need tsx? I am still kinda new to typescript

tsx is basically an extension of jsx which is widely used in reactjs. If you're new to react, reading this article may help:
https://facebook.github.io/react/docs/jsx-in-depth.html
https://facebook.github.io/react/docs/hello-world.html

And maybe if necessary do a bit of tutorial (this is in ES6, not TypeScript but logically works):
https://egghead.io/courses/react-fundamentals

Closing this issue as @jonathanhotono redirected to some good resources for TSX. Feel free to re-open if you have further issues.

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

Was this page helpful?
0 / 5 - 0 ratings

Related issues

waldekmastykarz picture waldekmastykarz  路  3Comments

mikeparkie picture mikeparkie  路  3Comments

nanddeepn picture nanddeepn  路  3Comments

byrongits picture byrongits  路  3Comments

zerovectorspace picture zerovectorspace  路  3Comments