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

Typescript picks wrong interface for type checking for React Native component state

$
0
0

Some of my classed do not pass type checking by ESLint with Typescript because of this error:

  Object literal may only specify known properties, and 'selectedIndex' does not exist in type '{ zoomLevel: number; markerPointId: number; isLocationEnabled: boolean; markerIdFromProps: number; userPosition: { latitude: number; angle: number; longitude: number; }; mapRotate: boolean; darkMode: boolean; selectedRock: { ...; }; isModalVisible: boolean; isRockModalVisible: boolean; points: any[]; }'.

Example of this code:

export interface MyProps extends ViewProps {  ...  initialPage: number;  ref?: React.Ref<MyComponent>;}interface MyState {  selectedIndex: number;}export default class MyComponent extends React.Component<  MyProps,  MyState> {  constructor(props: MyProps) {    super(props);    const {initialPage} = props;    this.state = {      selectedIndex: initialPage    };  }...}

Error is on init state and in using state.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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