Skip to content

Change render method in infinite mode.

Compare
Choose a tag to compare
@YIZHUANG YIZHUANG released this 28 Jul 14:57
· 259 commits to master since this release

Commit: e865fab

Issue: #48

Previously clones are only set once during the entire life cyle as the following:

componentDidMount(){
  this.setState({ clones: whatever });
}
render(){
  return (
    <>
     {this.state.clones.map.....}
    </>
    )
  }

Using such approach works, but does not allow for advanced customization. For example:

const MyComponent = () => {
 const [anyState, setAnyState] = useState(null);
return (
   <Carousel
    infinite={true}
    beforeChange={() => setAnyState('anything')}
   >
    <CarouselItem anyState={anyState} /> 
    // anyState will be null as always because Carousel item is not re-rendering. 
  </Carousel>
  )
}

This commit fixes the above.