rmariuzzo / react-new-window

🔲 Pop new windows in React, using `window.open`.
https://rmariuzzo.github.io/react-new-window/
MIT License
442 stars 107 forks source link

'NewWindow' cannot be used as a JSX component. #112

Closed Ofer-Gal closed 1 year ago

Ofer-Gal commented 2 years ago

I created component just like the example: `const Demo = () => (

Hi 👋

)` 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

rmariuzzo commented 1 year ago

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.