How to use the @react-navigation/core.withNavigation function in @react-navigation/core

To help you get started, we’ve selected a few @react-navigation/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keybase / client / shared / util / safe-navigation.tsx View on Github external
// @ts-ignore
        <Component
          ref={forwardedRef}
          {...rest}
          getParam={navigation.getParam}
          navigateAppend={this._navigateAppend}
          navigateUp={this._navigateUp}
        />
      )
    }
  }
  const WithForwardRef = React.forwardRef((props: WithSafeNavigationProps, ref) => (
    <WithSafeNavigation {...props} forwardedRef={ref} />
  ))
  WithForwardRef.displayName = `ForwardRef(WithSafeNavigation)`
  return withNavigation(WithForwardRef)
}
github react-navigation / native / src / createNavigationAwareScrollable.js View on Github external
export default function createNavigationAwareScrollable(Component: any) {
  const ComponentWithNavigationScrolling = withNavigation(
    class extends React.PureComponent<any> {
      static displayName = `withNavigationScrolling(${Component.displayName ||
        Component.name})`;

      _subscription: any;

      componentDidMount() {
        this._subscription = this.props.navigation.addListener(
          'refocus',
          () => {
            const scrollableNode = this.getNode();
            if (this.props.navigation.isFocused() && scrollableNode !== null) {
              if (scrollableNode.scrollToTop != null) {
                scrollableNode.scrollToTop();
              } else if (scrollableNode.scrollTo != null) {
                scrollableNode.scrollTo({ y: 0 });
github react-navigation / core / example / src / EventsStack.js View on Github external
return (
      <View
        style={{
          padding: 20,
          backgroundColor: getColorOfEvent(this.state.mode),
        }}
      >
        <Text style={{ color: 'white' }}>
          {key} {String(this.state.mode)}
        </Text>
      </View>
    );
  }
}

const FocusTag = withNavigation(FocusTagWithNav);

class SampleScreen extends React.Component {
  static navigationOptions = ({ navigation }) => ({
    title: 'Lorem Ipsum',
    headerRight: navigation.getParam('nextPage') ? (
      <Button
        title="Next"
        onPress={() => navigation.navigate(navigation.getParam('nextPage'))}
      />
    ) : null,
  });

  componentDidMount() {
    this.props.navigation.addListener('refocus', () => {
      if (this.props.navigation.isFocused()) {
        this.scrollView.scrollTo({ x: 0, y: 0 });
github react-navigation / web / src / Link.js View on Github external
? `/${pathAndParams.path}?${queryString.stringify(pathAndParams.params)}`
      : `/${pathAndParams.path}`;
    return (
      <a
        href={href}
        onClick={e => {
          navigation.dispatch(navAction);
          e.preventDefault();
        }}
      >
        {children}
      </a>
    );
  }
}
const Link = withNavigation(LinkWithNavigation);

export default Link;