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

Fix propTypes warnings #547

Merged
merged 3 commits into from
Sep 28, 2020
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
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