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

This expression is not callable typescript error

$
0
0

why I get this error:

This expression is not callable.  Type 'String' has no call signatures.ts(2349

Context:

import React, { createContext, useState } from 'react';enum StagesConnect = {  FIRST = 'FIRST',  SECOND = 'SECOND'}type ConnectProps = {  children: React.ReactNode;}export typeCreateUserContextStage = {  stages: StagesConnect;  setStage: React.Dispatch<React.SetStateAction<StagesConnect>> ;}export constCreateUserContext = createContext<CreateUserContextStage>({} asCreateUserContextStage);export constCreateUserProvider = ({  children}: ConnectProps) => {  const [stages, setStage] = useState<StagesConnect>(StagesConnect.Instructions);  return <CreateUserContext.Provider value={{stages, setStage}}>{children}</CreateUserContext.Provider>}

I want to display now the current Stage.The problem is I get the error message...

Code:

const CreateUser = ({}: ICreateUser) => {  const stages = useContext<CreateUserContextStage>(CreateUserContext);  return (<AfterInteractions placeholder={<View style={s.container}><Loader color='#fff' size='large' /></View>}><View style={s.container}><Text style={globalText.title}>Create Account!</Text>        { stages.stages === 'FIRST' (<Form />)        }</View></AfterInteractions>  )}

the error comes on this line:

stages.stages === 'FIRST'<-

I dont understand because if I console log my context then I get the right object:

Object {"setStage": [Function bound dispatchAction],"stages": "FIRST",}

but if I access the stages then its not callable, why?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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