react-tweenful icon indicating copy to clipboard operation
react-tweenful copied to clipboard

Support forwardRef in Tweenfu.div

Open roackb2 opened this issue 3 years ago • 1 comments

I was trying to create a ref in Tweenful.div, but it appears that the it's a function component wrapper, so React shows warnings as following:

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

In my constructor I created a ref

        this.container = React.createRef();

And this is my code using Tweenful.div

            <Tweenful.div
                ref={this.container}
                className="tween-box row ml-2 mb-2 mr-2 mt-2"
                duration={1500}
                easing={elastic(1, 0.25)}
                style={{ position: 'relative' }}
                animate={animate}>
                // child components
            </Tweenful.div>

roackb2 avatar Sep 07 '20 02:09 roackb2

Oh, yeah, I haven't thought of that. You need the ref to access the div right? You'll push a fix these days.

teodosii avatar Sep 10 '20 08:09 teodosii