Linked Questions

0 votes
1 answer
228 views

I'm trying to update the same state from an asynchronous callback launched in parallel. The problem is that each one of the asynchronous callback always has the init state and doesn't get the updated ...
Ricardo Garcia Landete's user avatar
1 vote
0 answers
61 views

As the title says I have an error that says "cannot read property 'length' of undefined" when I'm handling change in FormInput. However, if I refactor my SignUp component from functional to ...
Allen's user avatar
  • 11
0 votes
0 answers
50 views

I've got an API to work with where I first need to get a list of ids before calling APIs to get more details of each item. I'm having trouble storing the result of the details in state. Somethings ...
Barry Michael Doyle's user avatar
321 votes
19 answers
662k views

What is the correct way of updating state, in a nested object, in React with Hooks? export Example = () => { const [exampleState, setExampleState] = useState( {masterField: { fieldOne: &...
isaacsultan's user avatar
  • 3,994
8 votes
1 answer
23k views

The react.js site has the following code on this page: const [count, setCount] = useState(0); ... <button onClick={() => setCount(count + 1)}> But since count is updated based on its ...
user13647644's user avatar
5 votes
2 answers
12k views

Imagine a scenario that there's a same operation through different values (For instance generating a custom html element for different input values); in the case of using a component class, I would ...
Elmira Khodaee's user avatar
3 votes
4 answers
2k views

React 16.9 I am aware that this class component state: class JustAnotherCounter extends Component { state = { count: 0 }; is the equivalent of using Hooks useState: function ...
John D's user avatar
  • 295
1 vote
2 answers
5k views

I'm trying to create a Twitter clone, and I'm having troubles with my news feed. Basically it pulls tweets from my firebase database for each user followed by the current user. So say you follow Jon ...
Mael Landrin's user avatar
0 votes
1 answer
6k views

I'm getting this error as soon as I input a second character: Uncaught TypeError: Cannot create property 'value' on string 'a' The code so far: function App() { const [object, setObject] = useState(...
Anushka Chauhan's user avatar
2 votes
2 answers
1k views

The state doesn't update the value even though I'm setting it to the oldvalue + 1. When logging out the values of ltrNewValue or rtlNewValue it's always the same. It's as it's being overwritten by the ...
Tormod Flesjø's user avatar
4 votes
2 answers
2k views

How do I pass err to errors : {} here ? const data = { name: "", errors: {} } const [values, setValues] = useState(data) const handleSubmit = () => { const err = validate(); // I receive an ...
Sushilzzz's user avatar
  • 587
0 votes
1 answer
2k views

i am trying to submit a form using patch in react js i want to merge Values & formData so that i can pass it a single variable throgh the api but i am getting error when i do that i have also ...
vivek kn's user avatar
  • 305
0 votes
2 answers
2k views

Currently, I have many checkboxes which all obviously correlate to boolean values that need to be passed on onSubmit. I had something like this initially: const [value, setValue] = React.useState({ ...
user avatar
2 votes
3 answers
834 views

I am trying to make a basketball scoreboard app in React and have each team as it's own object with score, field goals made, and field goal attempts as properties. I have buttons that increment all of ...
alecnazzy's user avatar
0 votes
1 answer
407 views

I am trying to console log the two fields from my sign up page. However, the item appears in the console for about a second and then disappears. Any help is appreciated. Please find my code for the ...
new_hello_world's user avatar

15 30 50 per page