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

Property missing type in React/Typescript while trying to pass a bool and interface to component state?

$
0
0

I am new to React and Typescript and I can't find the correct way I should be passing these into the React.Componet state. My code still works as expected but I would like to know what I am doing wrong!

class App extends React.Component<{}, { isLoading: boolean, thisCoffeeShop: ICoffeeShop }> {constructor(props: Readonly<{}>) {    super(props);    this.state = {        isLoading: true                        }       }//....}

}

I assume its Typescript throwing me

"Property 'thisCoffeeShop' is missing in type '{ isLoading: true; }' but required in type 'Readonly<{ isLoading: boolean; thisCoffeeShop: ICoffeeShop; }>'."

Viewing all articles
Browse latest Browse all 6214

Trending Articles



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