Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/components/Pressable/PressableWithDelayToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import useThrottledButtonState from '../../hooks/useThrottledButtonState';

const propTypes = {
/** Ref passed to the component by React.forwardRef (do not pass from parent) */
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.instanceOf(React.Component)})]).isRequired,
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.instanceOf(React.Component)})]),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jayeshmangwani could you please help me understand in which case React.forwardRef won't pass a ref?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane Yes sure, the CopyTextToClipboard component uses the PressableWithDelayToggle Component as a child. And here, no ref passed to the PressableWithDelayToggle from CopyTextToClipboard so that the child component is getting the null value for innerRef And React.forwardRef will pass null value to ref

function CopyTextToClipboard(props) {
const copyToClipboard = useCallback(() => {
Clipboard.setString(props.text);
}, [props.text]);
return (
<PressableWithDelayToggle
text={props.text}
tooltipText={props.translate('reportActionContextMenu.copyToClipboard')}
tooltipTextChecked={props.translate('reportActionContextMenu.copied')}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


/** The text to display */
text: PropTypes.string,
Expand Down Expand Up @@ -67,6 +67,7 @@ const defaultProps = {
icon: null,
inline: true,
iconChecked: Expensicons.Checkmark,
innerRef: () => {},
};

function PressableWithDelayToggle(props) {
Expand Down