Learus / react-material-ui-carousel

A Generic carousel UI component for React using Material UI.
MIT License
550 stars 219 forks source link

index prop usage #197

Closed cccsso closed 2 years ago

cccsso commented 2 years ago

how do i use the index prop correctly? the documentation for it is very sparse. please consider adding an example usage in the docs!

i made a state variable for it const [index, setIndex] = useState(0)

then added it to the carousel: <Carousel autoPlay={false} index={index} />

i have a useEffect that sets the index to be index 0 when my data length changes useEffect(() => { setIndex(data.length <= 5 ? 0 : undefined) }, [data.length])

but the index isn't navigating to index 0, idk why

cccsso commented 2 years ago

omg nvm. index starts at 1 not 0

but still, would definitely be helpful if there were better documentation for it!