'Text' cannot be used as a JSX component

Hey there,

I migrating my widget to use TS and Webpack and React and im having an issue that results in the following TS error

‘Text’ cannot be used as a JSX component.
Its return type ‘FigmaDeclarativeNode’ is not a valid JSX element.
Type ‘undefined’ is not assignable to type ‘Element | null’.ts(2786)

Happy to provide any other info.

2 Likes

Same problem

Same issue here!

I got same issue when I imported React from ‘react’, before that it was fine. Turns out that as soon as you try importing react for any reason (I needed useEffect), TS gets confused about types because it starts using normal React types.

The solution is to never import React in the widget code. If you need useEffect or something, take it from Figma.widget like everything else