Questions tagged [react-native-state]
21 questions
3
votes
2 answers
React native: setState did not update immediately
I'm trying to make a TicTacToe game for an android app. The TicTacToe's game mode that I'm intended to make is Human-vs-Computer. But the problem is the program did not update the switching-procedure (setState) in my switchPlayer function as the…

BunnyHOPE
- 53
- 6
2
votes
0 answers
Why is my TextInput out of sync with state when I give rapid inputs?
I'm creating a typing race game with React Native which is producing an unexpected bug on Android.
When the user finishes typing a word/spacebar, I set the input state to an empty string.
However, if the user finishes typing a word/spacebar then…

Aria
- 33
- 5
2
votes
0 answers
React native doesn't update state after autocomplete in textinput
I'm working on a messaging app with the following code:
const MessageCentral = () => {
const [inputText, onChangeText] = useState('');
const [bodyText, updateText] = useState("");
const addMessage = () => {
updateText(bodyText + …

Ulysses
- 17
- 2
1
vote
1 answer
OnResume in react native screen of Android
I have a screen in react native for android.
I wanted to do some operation when particular screen(implemented in react-native) alone resumes as like fragment's onresume() in java/kotlin
How shall i achieve the fragment's onResume() concept in react…

Happy
- 1,031
- 10
- 26
1
vote
2 answers
TextInput onChangeText set useState value is not working in React Native Testing with Enzyme
I want to test that user should not navigate to any other screen if TextInput equals to "".
I have tried to put console logs to understand more correctly but the problem is now that, after input.simulate("changeText", "any@email.com"); happened…

Oğuzhan Atalay
- 160
- 2
- 14
1
vote
1 answer
React Native FlatList Unexpected behavior with on onViewableItemsChanged
I am trying to implement FlatList onViewableItemsChanged using Functional Component.
I Want to change state as the user scrolls.
Initially, I Wrote This
const [activeAlphabet,setAlphabet] = useState(0)
const onViewableItemsChanged…

Mritunjay Pathak
- 83
- 9
1
vote
1 answer
Why is React Native state not properly being set when I tap a button in navigationOptions?
I have a React Native screen/component in which there is a menu button in the top-left corner of the nav/header. When that button is tapped, I want to make a menu within the screen/component itself toggle open and shut.
For whatever reason though,…

HartleySan
- 7,404
- 14
- 66
- 119
0
votes
0 answers
React Native Linechart update
I'm trying to build a React native app to visualize ECG graph.
Here I'm taking the data from the ESP32 using Bluetooth. ECG digital data from ESP32 is posted for every 2milliseconds. I'm trying to fetch the data from the Bluetooth Socket when ever…
0
votes
1 answer
React-native: How to update parent's state from child component?
I've a parent-child component structure, where parent fetches data to be displayed and child component displays the data. I want to update parent's state from child component. I'm sending a handler function from parent to the child as a prop, which…

SJaka
- 712
- 13
- 40
0
votes
1 answer
React Native textInput clear
I have a textinput like this:
setClave(val)}
/>
and the component is:
const [clave, setClave] = useState('');
which is just for the…

Pepopig
- 15
- 4
0
votes
1 answer
Remove an item from FlatList render wrong items
I know that it has been asked several times, but in all the other threads the problem is that the author is manipulating the state directly - which I don't (hopefully).
I've got an array of posts that I get from the DB.
I want to be able to filter…

RedYoel
- 302
- 2
- 16
0
votes
2 answers
Convert class component state to functional component
I'm learning react native. I didn't figure out this problem. I have been using functional component in my project. Here is i don't understand to convert class component state :
constructor(props) {
super(props)
this.state = {
…

Золбоо О'
- 19
- 5
0
votes
1 answer
Is it possible a state that among two screen and able to setState from the two screens?
I have occured this problem on my project.I really confused what I'm gonna do.

Золбоо О'
- 19
- 5
0
votes
1 answer
Update style from state in react native with typescript
I am using react native with typescript, and I wanted to update my style property from the state. But it is giving me error.
const [VerifiedCheck, setIsVerifiedCheck] = useState("flex");

pratteek shaurya
- 850
- 2
- 12
- 34
0
votes
1 answer
Why does AsyncStorage save an empty array with the first click and then save the entered value only with the second button click in react native
I try to save the tasks in my ToDo app with AsyncStorage so that they can be retrieved after an app restart.
So far I have managed to save the tasks. However, an empty array is always saved in the first run. If I want to create a new task, it only…

Henning
- 3
- 2