Skip to content

Commit

Permalink
Merge pull request #547 from Expensify/marcaaron-fixWarnings
Browse files Browse the repository at this point in the history
Fix propTypes warnings
  • Loading branch information
Jag96 authored Sep 28, 2020
2 parents 7e99f8d + f9da6c1 commit 6b7d92c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/components/InvertedFlatList/BaseInvertedFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const propTypes = {
// renderItem rows. Web will have issues with FlatList
// if this is inaccurate.
initialRowHeight: PropTypes.number.isRequired,

// Passed via forwardRef so we can access the FlatList ref
innerRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({current: PropTypes.instanceOf(FlatList)})
]).isRequired,
};

const defaultProps = {
Expand Down
12 changes: 10 additions & 2 deletions src/components/InvertedFlatList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import React, {
useCallback,
forwardRef
} from 'react';
import PropTypes from 'prop-types';
import BaseInvertedFlatList from './BaseInvertedFlatList';

const propTypes = {
// Passed via forwardRef so we can access the FlatList ref
innerRef: PropTypes.func.isRequired,
};

// This is copied from https://codesandbox.io/s/react-native-dsyse
// It's a HACK alert since FlatList has inverted scrolling on web
const InvertedFlatList = (props) => {
Expand All @@ -17,7 +23,7 @@ const InvertedFlatList = (props) => {
}, []);

useEffect(() => {
props.forwardedRef(ref.current);
props.innerRef(ref.current);
}, []);

useEffect(() => {
Expand Down Expand Up @@ -52,7 +58,9 @@ const InvertedFlatList = (props) => {
);
};

InvertedFlatList.propTypes = propTypes;

export default forwardRef((props, ref) => (
// eslint-disable-next-line react/jsx-props-no-spreading
<InvertedFlatList {...props} forwardedRef={ref} />
<InvertedFlatList {...props} innerRef={ref} />
));
7 changes: 7 additions & 0 deletions src/page/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ const propTypes = {

// Array of report actions for this report
reportActions: PropTypes.objectOf(PropTypes.shape(ReportActionPropTypes)),

// The session of the logged in person
session: PropTypes.shape({
// Email of the logged in person
email: PropTypes.string,
}),
};

const defaultProps = {
reportActions: {},
session: {},
};

class ReportActionsView extends React.Component {
Expand Down

0 comments on commit 6b7d92c

Please sign in to comment.