Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to react 16.3 #246

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
},
"peerDependencies": {
"@babel/runtime": "^7.0.0",
"react": ">=0.14",
"react": "^16.3 || ^17",
"react-with-direction": "^1.3.1"
},
"dependencies": {
Expand Down
27 changes: 6 additions & 21 deletions src/withStyles.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable no-param-reassign */

import React from 'react';
import React, { forwardRef } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import getComponentName from 'airbnb-prop-types/build/helpers/getComponentName';
import ref from 'airbnb-prop-types/build/ref';

import EMPTY_STYLES_FN from './utils/emptyStylesFn';
import withPerf from './utils/perf';
Expand Down Expand Up @@ -233,10 +232,8 @@ export function withStyles(

return (
<WrappedComponent
// TODO: remove conditional once breaking change to only support React 16.3+
// ref: https://github.com/airbnb/react-with-styles/pull/240#discussion_r533497857
ref={typeof React.forwardRef === 'undefined' ? undefined : forwardedRef}
{...(typeof React.forwardRef === 'undefined' ? this.props : rest)}
ref={forwardedRef}
{...rest}
{...{
[themePropName]: theme,
[stylesPropName]: styles,
Expand All @@ -247,21 +244,9 @@ export function withStyles(
}
}

// TODO: remove conditional once breaking change to only support React 16.3+
// ref: https://github.com/airbnb/react-with-styles/pull/240#discussion_r533497857
if (typeof React.forwardRef !== 'undefined') {
WithStyles.propTypes = {
forwardedRef: ref(),
};
}

// TODO: remove conditional once breaking change to only support React 16.3+
// ref: https://github.com/airbnb/react-with-styles/pull/240#discussion_r533497857
const ForwardedWithStyles = typeof React.forwardRef === 'undefined'
? WithStyles
: React.forwardRef((props, forwardedRef) => (
<WithStyles {...props} forwardedRef={forwardedRef} />
));
const ForwardedWithStyles = forwardRef((props, ref) => (
<WithStyles {...props} forwardedRef={ref} />
));

// Copy the wrapped component's prop types and default props on WithStyles
if (WrappedComponent.propTypes) {
Expand Down