Skip to main content
Question

'Text' cannot be used as a JSX component

  • 28 February 2024
  • 3 replies
  • 716 views

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.

Yuri_Mikhin1

Same problem


Same issue here!


  • June 12, 2024

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings