Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6211

How to define navigation proptype in React navigation 5x

$
0
0

I am working new project. I started using typescript in this project. When I started the new project, I used react navigation 5x version. My question, how to define interface destructed navigation prop type in react navigation 5x version ? I don't use any type. I readed document react navigation, but i don't find my question. Thanks a lot. Have a nice days. 👋

import React from 'react';
import {Button, Text, SafeAreaView} from 'react-native';
import {inject, observer} from 'mobx-react';
import {Col, Grid} from 'react-native-easy-grid';
import Stores from '../../stores/storeIdentifier';
import ThemeStore from '../../stores/themeStore';

interface Props {
  navigation: any;
}
interface InjectedProps extends Props {
  themeStore: ThemeStore;
}

export function ModalComponent(props: Props) {
  const {themeStore, navigation} = props as InjectedProps;
  return (
    <SafeAreaView style={themeStore.styleSheet.globalModal__container}>
      <Grid>
        <Col
          style={[
            themeStore.styleSheet.alignCenter,
            themeStore.styleSheet.justifyCenter,
          ]}>
          <Text>Welcome to Global Modal 👋</Text>
          <Button onPress={() => navigation.goBack()} title="Back" />
        </Col>
      </Grid>
    </SafeAreaView>
  );
}
export const Modal = inject(Stores.ThemeStore)(observer(ModalComponent));

Viewing all articles
Browse latest Browse all 6211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>