-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,26 @@ import React from 'react'; | |
import {InnerSlider} from './inner-slider'; | ||
import assign from 'object-assign'; | ||
import json2mq from 'json2mq'; | ||
import ResponsiveMixin from 'react-responsive-mixin'; | ||
import createReactClass from 'create-react-class'; | ||
import defaultProps from './default-props'; | ||
import enquire from 'enquire.js'; | ||
|
||
var Slider = createReactClass({ | ||
mixins: [ResponsiveMixin], | ||
innerSlider: null, | ||
innerSliderRefHandler: function (ref) { | ||
this.innerSlider = ref; | ||
}, | ||
getInitialState: function () { | ||
return { | ||
export default class Slider extends React.Component { | ||
This comment has been minimized.
Sorry, something went wrong.
devrelm
|
||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
breakpoint: null | ||
}; | ||
}, | ||
componentWillMount: function () { | ||
this._responsiveMediaHandlers = []; | ||
this.innerSliderRefHandler = this.innerSliderRefHandler.bind(this) | ||
} | ||
innerSliderRefHandler(ref) { | ||
this.innerSlider = ref; | ||
} | ||
media(query, handler) { | ||
enquire.register(query, handler); | ||
this._responsiveMediaHandlers.push({query, handler}); | ||
} | ||
componentWillMount() { | ||
if (this.props.responsive) { | ||
var breakpoints = this.props.responsive.map(breakpt => breakpt.breakpoint); | ||
breakpoints.sort((x, y) => x - y); | ||
|
@@ -33,7 +37,7 @@ var Slider = createReactClass({ | |
} | ||
this.media(bQuery, () => { | ||
this.setState({breakpoint: breakpoint}); | ||
}); | ||
}) | ||
}); | ||
|
||
// Register media query for full screen. Need to support resize from small to large | ||
|
@@ -43,21 +47,27 @@ var Slider = createReactClass({ | |
this.setState({breakpoint: null}); | ||
}); | ||
} | ||
}, | ||
} | ||
|
||
slickPrev: function () { | ||
componentWillUnmount() { | ||
this._responsiveMediaHandlers.forEach(function(obj) { | ||
enquire.unregister(obj.query, obj.handler); | ||
}); | ||
} | ||
|
||
slickPrev() { | ||
this.innerSlider.slickPrev(); | ||
}, | ||
} | ||
|
||
slickNext: function () { | ||
slickNext() { | ||
this.innerSlider.slickNext(); | ||
}, | ||
} | ||
|
||
slickGoTo: function (slide) { | ||
slickGoTo(slide) { | ||
this.innerSlider.slickGoTo(slide) | ||
}, | ||
} | ||
|
||
render: function () { | ||
render() { | ||
var settings; | ||
var newProps; | ||
if (this.state.breakpoint) { | ||
|
@@ -90,6 +100,4 @@ var Slider = createReactClass({ | |
); | ||
} | ||
} | ||
}); | ||
|
||
module.exports = Slider; | ||
} |
7 comments
on commit b798b1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make a new release? The latest release uses the package create-react-class
which doesn't set displayName
on the component. So it's a regression. See facebook/react#9384 (comment) and babel/babel#5554
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still we are using mixins in https://github.com/akiran/react-slick/blob/master/src/inner-slider.js
We have to refactor it to avoid mixins usage and before removing create-react-class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meanwhile we can set displayName
on the component manually to fix the regression 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please release a new version. In the latest version you have dependencies on enzyme and react-test-render which pulls in all the test stuff on production for us and because of that we now have a missing peer dependency because react-test-render has a peer dependency on [email protected], but we use 15.4.
We reverted for now to 0.14.7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should enquire.js be a regular dependency rather than a devDependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but cause #273 !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but cause #273 !!
Should put in dependencies!
#719