plougsgaard / react-timeout

Component wrapper for setTimeout et al that cleans up after itself.
127 stars 17 forks source link

Alert: `ref` is not a prop #119

Closed jrock17 closed 4 years ago

jrock17 commented 5 years ago

Getting this React warning from this component. Any ideas of a fix?

2019-11-06_11-51-25

plougsgaard commented 4 years ago

I haven't seen this myself, but it could be to do with (recent?) changes in React. Which version are you running and are you just using the package normally? I assume you're not messing around with refs or anything.

ldanet commented 4 years ago

Same here with a slightly different message: Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()? Check the render method of `ReactTimeout` Using React@16.12.0

Not doing anything with refs in the component or its parent.

plougsgaard commented 4 years ago

Thanks for the confirmation @ldanet - I probably have to put together a version that's more suited for "new React"!

jrock17 commented 4 years ago

Sorry for the delayed response. I'm using 16.8.3 and nothing funky with refs.

I think react-timeout is using 'ref' and recent versions of React throw this warning. Here is some info: https://stackoverflow.com/questions/38089895/react-ref-is-not-a-prop

ziaulrehman40 commented 4 years ago

This is keeping me from using this library.

plougsgaard commented 4 years ago

Will look at it shortly.

ziaulrehman40 commented 4 years ago

Thanks a lot @plougsgaard for your efforts. :+1:

jrock17 commented 4 years ago

Any update on this one? Thanks!

pnghai commented 4 years ago

I got the same error, too

afilp commented 4 years ago

Does someone know what needs to be changed in the code in order for the React.forwardRef to work properly? As it is now we can have access to the wrapped Class component through component.getWrappedInstance() though.