From 7b299602ce307a2f9268b1dd0eb191c0db4cadb4 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Fri, 25 Sep 2020 16:55:38 -0700 Subject: [PATCH 1/2] Fix propTypes warnings --- .../InvertedFlatList/BaseInvertedFlatList.js | 3 +++ src/components/InvertedFlatList/index.js | 12 ++++++++++-- src/page/home/report/ReportActionsView.js | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/InvertedFlatList/BaseInvertedFlatList.js b/src/components/InvertedFlatList/BaseInvertedFlatList.js index e753ff4e9bd9..0e9cadbad52c 100644 --- a/src/components/InvertedFlatList/BaseInvertedFlatList.js +++ b/src/components/InvertedFlatList/BaseInvertedFlatList.js @@ -16,6 +16,9 @@ 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.ref.isRequired, }; const defaultProps = { diff --git a/src/components/InvertedFlatList/index.js b/src/components/InvertedFlatList/index.js index baa394645e27..54602334355e 100644 --- a/src/components/InvertedFlatList/index.js +++ b/src/components/InvertedFlatList/index.js @@ -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.ref.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) => { @@ -17,7 +23,7 @@ const InvertedFlatList = (props) => { }, []); useEffect(() => { - props.forwardedRef(ref); + props.innerRef(ref.current); }, []); useEffect(() => { @@ -52,7 +58,9 @@ const InvertedFlatList = (props) => { ); }; +InvertedFlatList.propTypes = propTypes; + export default forwardRef((props, ref) => ( // eslint-disable-next-line react/jsx-props-no-spreading - + )); diff --git a/src/page/home/report/ReportActionsView.js b/src/page/home/report/ReportActionsView.js index 18b2ffead18d..de1e693e8189 100644 --- a/src/page/home/report/ReportActionsView.js +++ b/src/page/home/report/ReportActionsView.js @@ -24,6 +24,12 @@ 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 = { From 3b7f06a0ce42973ff9cf9e3dce18fa7bd50f08a7 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Fri, 25 Sep 2020 17:06:33 -0700 Subject: [PATCH 2/2] fix mo better prop types --- src/components/InvertedFlatList/BaseInvertedFlatList.js | 5 ++++- src/components/InvertedFlatList/index.js | 2 +- src/page/home/report/ReportActionsView.js | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/InvertedFlatList/BaseInvertedFlatList.js b/src/components/InvertedFlatList/BaseInvertedFlatList.js index 0e9cadbad52c..09f856f2aaf1 100644 --- a/src/components/InvertedFlatList/BaseInvertedFlatList.js +++ b/src/components/InvertedFlatList/BaseInvertedFlatList.js @@ -18,7 +18,10 @@ const propTypes = { initialRowHeight: PropTypes.number.isRequired, // Passed via forwardRef so we can access the FlatList ref - innerRef: PropTypes.ref.isRequired, + innerRef: PropTypes.oneOfType([ + PropTypes.func, + PropTypes.shape({current: PropTypes.instanceOf(FlatList)}) + ]).isRequired, }; const defaultProps = { diff --git a/src/components/InvertedFlatList/index.js b/src/components/InvertedFlatList/index.js index 54602334355e..c15ea3c6f6ea 100644 --- a/src/components/InvertedFlatList/index.js +++ b/src/components/InvertedFlatList/index.js @@ -9,7 +9,7 @@ import BaseInvertedFlatList from './BaseInvertedFlatList'; const propTypes = { // Passed via forwardRef so we can access the FlatList ref - innerRef: PropTypes.ref.isRequired, + innerRef: PropTypes.func.isRequired, }; // This is copied from https://codesandbox.io/s/react-native-dsyse diff --git a/src/page/home/report/ReportActionsView.js b/src/page/home/report/ReportActionsView.js index de1e693e8189..f844e13816e1 100644 --- a/src/page/home/report/ReportActionsView.js +++ b/src/page/home/report/ReportActionsView.js @@ -34,6 +34,7 @@ const propTypes = { const defaultProps = { reportActions: {}, + session: {}, }; class ReportActionsView extends React.Component {