Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

useLinkPressHandler

// React Router v6 (Native)
// Same as 'useLinkClickHandler' from 'react-router-dom'
// returns a press event handler for custom <Link> 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 (
    <TouchableHighlight
      {...rest}
      onPress={e => {
        onPress?.(e);
        !e.defaultPrevented && handlePress(e);
      }}
    />
  );
}
Source by reactrouter.com #
 
PREVIOUS NEXT
Tagged: #useLinkPressHandler
ADD COMMENT
Topic
Name
8+8 =