📜  useLinkPressHandler - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:28.100000             🧑  作者: Mango

代码示例1
// React Router v6 (Native)
// Same as 'useLinkClickHandler' from 'react-router-dom'
// returns a press event handler for custom  navigation.
import { TouchableHighlight } from 'react-native';
import { useLinkPressHandler } from 'react-router-native';

function Link({ onPress, replace = false, state, to, ...rest }) {
  let handlePress = useLinkPressHandler(to, {
    replace,
    state,
  });

  return (
     {
        onPress?.(e);
        !e.defaultPrevented && handlePress(e);
      }}
    />
  );
}