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

How to import a reusable component from theme folder in react native?

$
0
0

I want to import a reusable Button component from theme folder.

This is the path of the Button component:

\app\theme\components\Button.ts

And this is the code of Button.ts

import { typography } from "theme/typography";import { ButtonProps } from "react-native-elements";export const Button = {titleStyle: {    fontSize: typography.size,    fontFamily: typography.primaryMedium,    lineHeight: typography.size,    letterSpacing: 0,    marginHorizontal: typography.size},containerStyle: {    borderRadius: typography.size * 2 + typography.size * 2},buttonStyle: {    borderRadius: typography.size * 2 + typography.size}} as ButtonProps

And this is the component in which I want to import: organizationdetails-screen.tsx.

It's path is \app\screens\superadmin-screens\organizationdetails-screen.tsx.

I am trying to import the Button like this

import { Button } from '../../theme/components/Button';

But I am getting this error

enter image description here

I am using the Button like this:

<Button     title="Add User"     onPress={() => this.props.navigation.navigate('AddNewUser')}/>

When I hover over the button in Visual Studio Code it shows this error:

enter image description here

How do I import this reusable Button?


Viewing all articles
Browse latest Browse all 6211

Trending Articles



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