amio / re-carousel

Minimal carousel component for React.
https://amio.github.io/re-carousel/
273 stars 50 forks source link

It always shows warning with string ref and doesn't show carousel #148

Open ilyamordasov opened 3 years ago

ilyamordasov commented 3 years ago

When I try to use it within React App

<Row>
                <Col>
                    <Carousel loop widgets={[IndicatorDots]}>
                        {
                            (this.state.places !== undefined)
                            ?
                                this.state.places.map( (x, index) => {
                                    return <div key={index} ><Zone name={index} callModal={this.justBook} data={x}/></div>
                                })
                            : null
                        }
                    </Carousel>
                </Col>
            </Row>

I get the warning

Warning: A string ref, "wrapper", has been found within a strict mode tree. String refs are a source of potential bugs and should be avoided. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref
div
t@http://localhost:3000/static/js/vendors~main.chunk.js:12438:7
div
./node_modules/react-bootstrap/esm/Col.js/Col<@http://localhost:3000/static/js/vendors~main.chunk.js:14528:18
div
./node_modules/react-bootstrap/esm/Row.js/Row<@http://localhost:3000/static/js/vendors~main.chunk.js:18605:18
div
./node_modules/react-bootstrap/esm/Container.js/Container<@http://localhost:3000/static/js/vendors~main.chunk.js:14725:18
Splash@http://localhost:3000/static/js/main.chunk.js:830:5
SignIn@http://localhost:3000/static/js/main.chunk.js:626:5
App

If I add ref={this.wrapper}, where this.wrapper = React.createRef() it doesn't help. If I comment out all carousel component, there are no errors

marcancabrera commented 3 years ago

I have the same problem, I tried with:

npm i --save-dev @types/re-carousel

But I didn't get nothing.