fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 437 forks source link

Issue with Element and ScrollLink #506

Open tal-rofe opened 2 years ago

tal-rofe commented 2 years ago

I have the following error when trying to use either in JSX:

'Element' cannot be used as a JSX component.
  Its instance type 'Element' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.

Simple code:

import { Element } from 'react-scroll';
.
.
.
    return (
        <Element className={classes['sellersSectionInner']} name="sellerSection">
            x
        </Element>
    );

Versions:

"react": "18.0.0",
        "react-dom": "18.0.0",
"react-scroll": "1.8.6",
        "@types/react": "18.0.2",
        "@types/react-dom": "18.0.0",
        "@types/react-scroll": "1.8.3",
lensbart commented 2 years ago

Same issue here, since updating @types/react. Temporarily fixed by downgrading @types/react from 18.0.5 to 17.0.43

samstr commented 2 years ago

Same issue here. I suspect it might be related to react types removing the children prop from the FC type. After updating @types/react my codebase as absolutely filled with these warnings.

tal-rofe commented 2 years ago

Same issue here. I suspect it might be related to react types removing the children prop from the FC type. After updating @types/react my codebase as absolutely filled with these warnings.

Can you specify your changes/fix please? What is the @types/react version you used to fix it?

Moreover, how does your code look like with this "children" issue now?

lensbart commented 2 years ago

@tal-rofe does my comment above answer your first two questions?

tal-rofe commented 2 years ago

@tal-rofe does my comment above answer your first two questions?

I know it will solve it. I got a Renovate upgrade PR which was failed due to the error described. Right now my application works with lower version.

My wish is to have it working with higher versions of course

fisshy commented 2 years ago

Will try to fix this asap, will also accept PR's if someone solves it before me :)

Jagatmachines commented 2 years ago

@fisshy is following up with the conversation above. Is this issue fixed? I'm getting the same issue now also

fisshy commented 2 years ago

@fisshy is following up with the conversation above. Is this issue fixed? I'm getting the same issue now also

No sorry, it has not been fixed.. I must have forgotten it.

niende commented 1 year ago

@fisshy This doesn't seem to be fixed yet, are there any news on this?

Simonymous commented 1 year ago

Temporary Fix: Add react 18 as resolution in your package.json to force the use of react 18 for react-scroll: "resolutions": { "@types/react": "^18.0.28" }

calebwilson706 commented 1 year ago

Are there any updates on this?

lensbart commented 1 year ago

@calebwilson706 can you try with the following in your package.json?

    "devDependencies": {
        "@types/react": "^18.2.18",
        "@types/react-dom": "^18.2.7",
    }

Thanks.