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

state in React Native don't update

$
0
0

I cannot update state in useState coding in React Native. component is styled TextInput.What I do wrong that state don't see text input from SearchField ?

export const TabOneScreen: FC<IProps> = ({ navigation }) => {  const [userName, setUserName] = useState("jan");  useEffect(() => {    fetch(`https://api.github.com/users/${userName}`)      .then((response) => response.json())      .then((json) => console.log(json));  }, [userName]);  const handleUserName = (value: string) => {    setUserName(value);  };  return (<StyledContainer><SearchField onChangeText={(value: string) => handleUserName(value)} /><Text>{userName}</Text><DetailsField backgroundColor={colors.whiteColor} /><Button        color={colors.buttonBackground}        title="Show more"        onPress={() => {          navigation.navigate("DetailsScreen");        }}      /></StyledContainer>  );};

Viewing all articles
Browse latest Browse all 6365

Trending Articles



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