react-mosaic icon indicating copy to clipboard operation
react-mosaic copied to clipboard

Type 'import(".../node_modules/.pnpm/@[email protected]/node_modules/@types/react/jsx-runtime").JSX.Element' is not assignable to type 'JSX.Element'.

Open winstonpurnomo opened this issue 6 months ago • 3 comments

Trying to do this code:

<Mosaic
        renderTile={(id: string, path) => (
          <MosaicWindow path={path} title={`Window ${id}`}>
            <h1>Hello {id}!</h1>
          </MosaicWindow>
        )}
        initialValue={{
          direction: "row",
          first: "a",
          second: "b",
        }}
      />

With react and react-dom version 19.1.0 and

"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",

I get the error:

Type 'import(".../node_modules/.pnpm/@[email protected]/node_modules/@types/react/jsx-runtime").JSX.Element' is not assignable to type 'JSX.Element'

Is this because React 19 is not supported yet? is there a workaround?

winstonpurnomo avatar Jun 22 '25 14:06 winstonpurnomo

I encountered it too. How did you solve it ?

CharlesSpace avatar Jul 31 '25 13:07 CharlesSpace

I have not solved this issue. Ended up using a different library.

winstonpurnomo avatar Jul 31 '25 18:07 winstonpurnomo

import type { MosaicNode} from 'react-mosaic-component'

export type ViewId = 'a' | 'b' | 'c'

export const Mosaic = memo(() => {
  const [originLayout] = useState<MosaicNode<ViewId>>({
    direction: 'row',
    first: 'a',
    second: {
      direction: 'column',
      first: 'b',
      second: 'c'
    },
    splitPercentage: 40
  })

  return (
    <MosaicComponent<ViewId>
      renderTile={(id, path) => {
        return (
          <MosaicWindow<ViewId>
            path={path}
            title={TITLE_MAP[id]}
            toolbarControls={
              <div className="cursor-pointer flex items-center w-30px justify-center">
                <ExpandButton path={path} />
              </div>
            }
          >
            <h1>{TITLE_MAP[id]}</h1>
          </MosaicWindow>
        )
      }}
      initialValue={originLayout}
    />
  )
})

you can try it, like this

Downgrade react 19 to react 18, and there will be no such error

CharlesSpace avatar Aug 01 '25 10:08 CharlesSpace