react-reverse-portal icon indicating copy to clipboard operation
react-reverse-portal copied to clipboard

Support for Preact

Open derekbking opened this issue 2 years ago • 1 comments

I have been using this library with React and it has been extremely helpful and I haven't encountered any problems with it. Recently I started working on a project in Preact and I can't seem to get the portals to work properly.

I am getting the following errors:

src/app.tsx:23:11 - error TS2607: JSX element class does not support attributes because it does not have a 'props' property.

23           <portals.OutPortal node={portalNode}></portals.OutPortal>
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/app.tsx:23:12 - error TS2786: 'portals.OutPortal' cannot be used as a JSX component.
  Its instance type 'OutPortal<unknown>' is not a valid JSX element.
    Type 'OutPortal<unknown>' is missing the following properties from type 'Component<any, any>': state, props, context, setState, forceUpdate

23           <portals.OutPortal node={portalNode}></portals.OutPortal>
              ~~~~~~~~~~~~~~~~~

src/ThruModal.tsx:49:7 - error TS2607: JSX element class does not support attributes because it does not have a 'props' property.

49       <portals.InPortal node={portalNode}>
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/ThruModal.tsx:49:8 - error TS2786: 'portals.InPortal' cannot be used as a JSX component.
  Its instance type 'InPortal' is not a valid JSX element.
    Type 'InPortal' is missing the following properties from type 'Component<any, any>': state, props, context, setState, forceUpdate

49       <portals.InPortal node={portalNode}>
          ~~~~~~~~~~~~~~~~

Is this library compatible with Preact? I should mention I am using Vite / rollup to create my builds where in the past when using React I used react-scripts / web-pack.

derekbking avatar Nov 23 '22 18:11 derekbking

No idea I'm afraid. I've never really used Preact beyond basic messing around, and I'm not sure how the relevant internals differ.

If there are changes required, PRs are welcome!

pimterry avatar Nov 24 '22 13:11 pimterry