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

React Native [TypeError: Cannot read property 'startsWith' of undefined]?

$
0
0

I'm getting this error when I put my Javascipt code to a Typescript project.In Javascript project its worked fine but when I put the code into a Typescript project I got the error.

Is there any mistake in coding?

Here's the code :

const createPDF = async() => {    let Options = {      html: '<h1>test</h1>',      fileName: 'test',      directory: 'Download',    };    let file = await RNHTMLtoPDF.convert(Options)    Alert.alert('Alert','Successfully exported file:'+ file.filePath,[      {text:'Cancel',style:'cancel'},      {text:'Open',onPress:()=>openFile(file.filepath)}    ],{cancelable:true});  }  const openFile = (filepath: any) => {    const path = filepath;    FileViewer.open(path)    .then(()=>{      //success      console.log(`Successfully export PDF file`);    })    .catch(error => {      console.log(error);    });  }
LOG      [TypeError: Cannot read property 'startsWith' of undefined]

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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