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

React Converting JSX application to Typescript

$
0
0

I am keeping my code short as possible to remove confusion, actually i am trying to convert my application built on React jsx to React Typescript thus (tsx file).

Error that i am receiving is - '[ts] Property 'state' does not exist on type 'App'.any ALSO same for '[ts] Property 'setState' does not exist on type 'App'.any'Please help me on this ...

interface STATE {  loading: boolean};interface PROPS {};export default class App extends Component<STATE, PROPS> {  constructor(props:any) {    super(props);    this.state = {      fruitsData : [],      loading: false    };  }  componentDidMount() {    this.setState({      loading: true    });    //Further functions present here plus call to service and binding the      data received to the array fruitsData  }

My package.json

 {"name": "example","version": "0.1.0","private": true,"devDependencies": {"@types/classnames": "^2.2.3","@types/node": "^4.0.35","classnames": "^2.2.5","gh-pages": "^0.12.0","react": "^15.5.4","react-dom": "^15.5.4","react-scripts": "0.9.5","typescript": "^2.7.0-insiders.20171214"  },"dependencies": {"@types/react": "^16.0.34","@types/react-dom": "^16.0.3","awesome-typescript-loader": "^3.4.1","react-search-box": "0.0.4"  },"scripts": {"start": "react-scripts start","build": "react-scripts build","test": "react-scripts test --env=jsdom","eject": "react-scripts eject","predeploy": "npm run build","deploy": "gh-pages -d build"  }}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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