Skip to content

Commit

Permalink
modified SlideChangeHooks example to include state changes and remove…
Browse files Browse the repository at this point in the history
…d BeforeChangeSetState example
  • Loading branch information
laveesingh committed Mar 12, 2018
1 parent f786e5c commit c18b267
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 44 deletions.
2 changes: 0 additions & 2 deletions docs/demos.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ import CustomPaging from '../examples/CustomPaging'
import CustomSlides from '../examples/CustomSlides'
import AsNavFor from '../examples/AsNavFor'
import AppendDots from '../examples/AppendDots'
import BeforeChangeSetState from '../examples/BeforeChangeSetState'

export default class App extends React.Component {
render() {
return (
<div className='content'>
<BeforeChangeSetState />
<SimpleSlider />
<MultipleItems />
<Responsive />
Expand Down
35 changes: 0 additions & 35 deletions examples/BeforeChangeSetState.js

This file was deleted.

16 changes: 9 additions & 7 deletions examples/SlideChangeHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ import React, { Component } from 'react'
import Slider from '../src/slider'

export default class SlideChangeHooks extends Component {
state = {
activeSlide: 0,
activeSlide2: 0
}
render() {
const settings = {
dots: true,
infinite: true,
speed: 500,
speed: 1000,
slidesToShow: 1,
slidesToScroll: 1,
beforeChange: function (currentSlide, nextSlide) {
console.log('before change', currentSlide, nextSlide);
},
afterChange: function (currentSlide) {
console.log('after change', currentSlide);
},
beforeChange: (current, next) => this.setState({ activeSlide: next }),
afterChange: current => this.setState({ activeSlide2: current }),
};
return (
<div>
<h2>beforeChange and afterChange hooks</h2>
<p>BeforeChange => activeSlide: <strong>{this.state.activeSlide}</strong></p>
<p>AfterChange => activeSlide: <strong>{this.state.activeSlide2}</strong></p>
<Slider {...settings}>
<div><h3>1</h3></div>
<div><h3>2</h3></div>
Expand Down

0 comments on commit c18b267

Please sign in to comment.