rmariuzzo / react-new-window

πŸ”² Pop new windows in React, using `window.open`.

Home Page:https://rmariuzzo.github.io/react-new-window/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'NewWindow' cannot be used as a JSX component.

Ofer-Gal opened this issue Β· comments

I created component just like the example:
const Demo = () => ( <NewWindow> <h1>Hi πŸ‘‹</h1> </NewWindow> )
I get TypeScript Error:
(alias) class NewWindow
import NewWindow
'NewWindow' cannot be used as a JSX component.
Its instance type 'NewWindow' is not a valid JSX element.
Type 'NewWindow' is missing the following properties from type 'ElementClass': render, context, setState, forceUpdate, and 3 more.ts(2786)

I have to use TypeScript in SPFx
What am I doing wrong?
Thanks

Hi @Ofer-Gal! I'm really sorry for the long long reply. I tried to reproduce the issue without success. I used npm create vite (React+TS). Not sure, if the issue is gone because of minor updates I recently applied.

import { useState } from "react";
import NewWindow from "react-new-window";

const Demo = () => (
  <NewWindow>
    <h1>Hi πŸ‘‹</h1>
  </NewWindow>
);

function App() {
  const [open, setOpen] = useState(false);

  return (
    <div className="App">
      <button onClick={() => setOpen(true)}>Open</button>
      {open && <Demo />}
    </div>
  );
}

export default App;

If possible to reproduce again, I will be more than happy to help.