react-navigation-header-buttons icon indicating copy to clipboard operation
react-navigation-header-buttons copied to clipboard

how to React.forwardRef to HeaderButton

Open outaTiME opened this issue 4 years ago • 5 comments

hi guys, in need to pass ref to HeaderButton to get Touchable references, it could be possible to export HeaderButton as forwardRef,

Thanks !!

outaTiME avatar Jun 30 '20 03:06 outaTiME

hello and thanks for the comment!

need to pass ref to HeaderButton to get Touchable references

I'm planning to make a change to the underlying touchables soon, and I'll do it then. I'm waiting for https://github.com/software-mansion/react-native-gesture-handler/pull/1069 to be released

vonovak avatar Jun 30 '20 20:06 vonovak

hi @vonovak, great news thanks for your feedback, keep in touch 👍

outaTiME avatar Jun 30 '20 20:06 outaTiME

@outaTiME hi, out of curiosity, may I ask why you need the refs? Thanks!

vonovak avatar Aug 14 '20 22:08 vonovak

hi @vonovak, good one question 😄 I was needing this to pass the reference to the anchor of the ActionSheetIOS when iPad, but I solved it as follows:

<MaterialHeaderButtons>
  <Item
    title="more"
    iconName="more-horiz"
    onPress={(evt) => {
      const anchor = findNodeHandle(evt.nativeEvent.target);
      const options = ['Delete', 'Save', 'Cancel'];
      const destructiveButtonIndex = 0;
      const cancelButtonIndex = 2;
      showActionSheetWithOptions(
        {
          options,
          cancelButtonIndex,
          destructiveButtonIndex,
          // iPad only
          anchor,
        },
        (button_index) => {
          // action
        }
      );
    } 
  />
</MaterialHeaderButtons>

outaTiME avatar Aug 14 '20 23:08 outaTiME

@outaTiME hi! I updated the touchables implementation but I don't have time for the ref change; feel free to open a RP, thanks!

vonovak avatar Oct 18 '20 12:10 vonovak