use-state Questions
3
Solved
In my React app, I have a custom defined hook that holds a useState value internally, but the custom hook itself does not return any values.
If the value of its internal useState changes would this...
Disjuncture asked 11/6, 2022 at 16:15
1
I am building a little local dev/testing/documentation environment for some components which are used across different projects and so want to create them as individual npm packages.
Everything was...
Lithea asked 20/5, 2022 at 23:17
7
I used react.js Hooks with useState and useEffect, when I scroll-down and the screen comes down Header hides after 250 pixels. Now I want to know how to display Header using the react Hooks when I ...
Alacrity asked 6/10, 2021 at 22:12
7
Solved
I'm currently reducing / removing npm warnings on a React site.
A large number of these warnings are caused by the setState function as seen below, being 'unused'.
const [state, setState] = useStat...
Poltergeist asked 14/1, 2021 at 16:13
7
Solved
I'm using MUI library to create my React Js app.
Here I'm using the controlled Text Field component to create a simple search UI.
But there is something strange. The Text Field component loses focu...
Leech asked 30/11, 2021 at 4:27
17
So I'm trying to use useState in my nextjs app, but as soon as I add in the line of code to initialize useState it throws a popup error with the error message: TypeError: Cannot read properties of ...
Acidify asked 17/4, 2022 at 0:22
5
Solved
I've a series of user data elements which I'm collecting inside a React component using hooks.
const [mobile, setMobile] = useState('');
const [username, setUsername] = useState('');
const [email,...
Wamsley asked 19/1, 2020 at 20:3
4
React state shouldn't be mutated directly. But, what if the state is an instance of a class that shall be mutable with its own methods. Is there another way than having to deep-clone and re-instant...
Defibrillator asked 5/2, 2021 at 11:54
4
Solved
This is a component that render data from firebase storage and make it listed. What the function has to do is set the videos extracted from firebase storage to the useState. That way I can call vid...
Microscopy asked 12/4, 2022 at 18:54
3
Solved
Lets say I have a basic setup for checking whether a user is logged in or not:
import { createContext } from "react";
const UserContext = createContext<string | null>(null)
export d...
Intent asked 29/5, 2022 at 1:7
6
Solved
Like the title says, the localStorage I set registers the changes made to the todoList array and JSON.stringifys it; however, whenever I refresh the page the array returns to the default [] state.
...
Hedvig asked 12/5, 2022 at 22:34
9
Solved
Re-posting a similar question to my last because of a new issue. I'm trying to use context with hooks to manage authentication in my react app. I'm getting the error TypeError: Cannot destructure p...
Sheepherder asked 14/6, 2020 at 22:8
23
Solved
React hooks introduces useState for setting component state. But how can I use hooks to replace the callback like below code:
setState(
{ name: "Michael" },
() => console.log(this.state)
);
...
Lucillelucina asked 21/5, 2019 at 23:18
4
Solved
I'm trying to get the data from a form in which some fields are dynamic so that their names follow a pattern like the days of the week ending in 1 or 2.
In the onChange I send the name of the compo...
Golden asked 28/1, 2021 at 20:53
2
If I return a function from useEffect I can be sure that that function will run when a component unmounts. But React seems to wipe the local state before it calls my unmounting function.
Consider t...
Biebel asked 14/12, 2020 at 13:54
2
the useState hooks are great. I mainly use the useState hooks to initialise certain states, and I also pass the function to children components to change the states. However, I realise I am startin...
Superable asked 1/7, 2020 at 16:46
8
I have a problem and I do not undersatnd why the hook return undefined :
import React, { useEffect, useState } from 'react';
function App(){
const [globalVariable, setGlobalVariable] = useState...
2
It's a common React knowledge that having state initialized by props is bad if we don't make them in sync. This is considered fine:
import { useState, useEffect } from 'react';
export default func...
Pavyer asked 17/2, 2022 at 18:25
3
Solved
I've been fighting with this code for days now and I'm still not getting it right.
The problem:
I'm working with a form that has a dropzone. On submit handler, I need to save the images' url in an ...
Bisque asked 20/5, 2021 at 5:5
2
Solved
I just started with TypeScript, so please bear in mind. I am trying to implement a simple file upload in React/TS. In general, I don't think I understand how to initialize objects, like in useState...
Mechanical asked 22/10, 2020 at 18:9
6
Solved
I've just started learning React and got to know about the useState hook. I came across two different ways for setting the state for boolean data. So are these two approaches identical and if not, ...
Labelle asked 3/1, 2022 at 12:48
4
Solved
Unable to render useState, useEffect hooks in custom component package using microbundle & React
Hi I am trying to create a sample library using React 18.2.0 & Microbundle and Although library built successfully, but when it is consumed in the client app I'm getting the below error in cons...
Placeeda asked 11/7, 2022 at 16:52
1
Solved
I am using a React hook for parent/child component.
Now I have state in my parent component (companyIcon), which I need to update based on some validation in the child component. I pass validationC...
Variegation asked 10/7, 2022 at 15:28
7
Solved
I'm having some trouble with the React useState hook. I have a todolist with a checkbox button and I want to update the 'done' property to 'true' that has the same id as the id of the 'clicked' che...
Artemis asked 15/7, 2020 at 15:45
3
Solved
Should useEffect hook be used when it can be simplified using an event listener?
For example, in the below snippet code I use event listener to change some state and later useEffect hook to react t...
Latt asked 17/5, 2022 at 12:14
1 Next >
© 2022 - 2025 — McMap. All rights reserved.