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

imports/exports using the ~ sign

$
0
0

I have a components folder where I am defining components like this:

export const ResultAlert: FunctionComponent<ResultAlertProps> = ({  severity,  text,}) => {  const classes = useStyles();  return (<Alert className={classes.alert} severity={severity}>      {''}      {text}</Alert>  );};

In my components folder, I have made an index.tsx file that says:

export * from './alerts/ResultAlert';

Now, I need a way to make imports work like this:

import {ResultAlert} from '~/components';

Currently, this gives me an error that

Cannot find module '~/components' or its corresponding type declarations.

I have seen this work in the past but I am not sure how. What am I missing out? Do I need to setup any framework else for this?


Viewing all articles
Browse latest Browse all 6213

Trending Articles



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