Comments (4)
Sorry, it's in the docs. I mean, I can get a ref and then get the index.
https://github.com/theolampert/react-flickity-component#use-flickitys-api-and-events
Doc shows how to do it with class component. For functional, this works:
const Carousel = React.forwardRef(({ children }, externalRef) => {
return (
<Flickity
flickityRef={(carouselRef) => { if (externalRef) externalRef.current = carouselRef }}
>
{children}
</Flickity>
)
})
Then you call it like:
const carouselRef = useRef(null)
...
<Carousel ref={carouselRef}>
...
</Carousel>
from react-flickity-component.
Can I close the issue since you have figured it out?
from react-flickity-component.
Sure. Let's close it.
from react-flickity-component.
Sorry, it's in the docs. I mean, I can get a ref and then get the index.
https://github.com/theolampert/react-flickity-component#use-flickitys-api-and-eventsDoc shows how to do it with class component. For functional, this works:
const Carousel = React.forwardRef(({ children }, externalRef) => { return ( <Flickity flickityRef={(carouselRef) => { if (externalRef) externalRef.current = carouselRef }} > {children} </Flickity> ) })
Then you call it like:
const carouselRef = useRef(null) ... <Carousel ref={carouselRef}> ... </Carousel>
Sorry I am struggling to put together the final part, I have all that in place and the ref is working, but how do I use it with an onChange listener or similar ?
from react-flickity-component.
Related Issues (20)
- 'Module not found, can't resolve 'flickity' with CRA HOT 1
- Flickity-extensions support (hash/fullscreen/etc) HOT 5
- Using with flickity-as-nav-for - Typescript HOT 3
- prev/next arrow size problem in firefox browser HOT 1
- npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.14.0" from [email protected] HOT 7
- Force reload HOT 1
- Option "pauseAutoPlayOnHover" missing.
- Doesn't work well on Safari iOS 15 HOT 2
- Please i've been having issue using the flickityRef, i can't wrap my head around it HOT 1
- Storybook HOT 1
- after updating to flickity 3.0 carousel started to display slides one on top of the other HOT 1
- Updating flickity peerDependency and devDependency to 3.0.0 HOT 1
- Updating peer dependencies to support React v. 18 HOT 20
- Error children with typescript HOT 2
- [V4] ReferenceError: window is not defined HOT 4
- v4 does not include TypeScript type definitions HOT 1
- Is it possible to configure flickity to only show x amount of slides?
- reloadOnUpdate behaviour is not intuitive HOT 2
- warning " > [email protected]" has unmet peer dependency "flickity@^2.2.1".
- typescript import HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-flickity-component.