diff --git a/src/withStyles.js b/src/withStyles.js index 5b7d7d73..70ee8140 100644 --- a/src/withStyles.js +++ b/src/withStyles.js @@ -8,6 +8,7 @@ */ import React from 'react' +import PropTypes from 'prop-types'; import hoistStatics from 'hoist-non-react-statics' import StyleContext from './StyleContext' @@ -27,17 +28,24 @@ function withStyles(...styles) { } render() { - return + const {__$$withStylesRef, ...props} = this.props; + return } } const displayName = ComposedComponent.displayName || ComposedComponent.name || 'Component' - WithStyles.displayName = `WithStyles(${displayName})` + WithStyles.propTypes = { + __$$withStylesRef: PropTypes.func, + } WithStyles.contextType = StyleContext - WithStyles.ComposedComponent = ComposedComponent - return hoistStatics(WithStyles, ComposedComponent) + const ForwardedWithStyles = React.forwardRef((props, ref) => ) + + ForwardedWithStyles.ComposedComponent = ComposedComponent + ForwardedWithStyles.displayName = `WithStyles(${displayName})` + + return hoistStatics(ForwardedWithStyles, ComposedComponent); } }