Category "use-state"

getting error "TypeError: Cannot read properties of null (reading 'useState')" on useState usage react

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:

How to independently set a button click in react?

I am trying to figure out on how to set a button that can independently be disabled when using the .map function. So I created a state whenever the button is cl

Playing background music in a React app using Howler

So im using Howler to play background music when my React app is loaded. So I store ID of the instance of Howler(i.e is responsible for background music) using

want the app to save state separately according to each user in react native

I have a app that conducts a test and when the currently logged in user passes the test, the app shows a modal telling him that he has passed the test. I want t

React difference of using value in state vs value in object in state

I am getting different behaviour depending on whether I am using a boolvalue on with useState, or whether I am using a bool value inside an object with useState

How can I update the value from the database in React

When I edit the form here, I need to show the value in the database. so how can i get this value const dataValue = ndata.filter((obj) => obj._id === dataid )

Setting state in useEffect hook does not change state value

am writing an app in react native and i got a problem with useState and useEffect hooks. I would like to change increment state value by one every 10 seconds. H

state is not getting updated for a new user in react native

My app has a test sheet, if a user passes the test he is shown a passing screen and then the state is saved using asyncstorage. But the problem here is, let's s

Material-UI-Search Bar value not clearing

I am using the @material-ui-searchbar to filter data. I'm using the same container for multiple different pages to display the info. When ever I switch between

React state management rendering for one object or array of objects

I'm learning React and starting with handling state in a CRUD form via the useState Hook. Something like this: const [data, setData] = useState({}); where data

why i have to refresh/rewrite my code to make it work while trying to save the state for a specific user in react native

I am trying to make a test sheet for user. If he passes the test, he is directed to a pass screen and even after totally closing the app, when that specific use

Filter imported data by more than one dropdown box. (React)

Link to GitHub I have tried lots of things to try and get multiple dropdowns filtering the data but cannot figure it out, I've deleted some failed attempt so th

Firestore & React: Update the Same State in Multiple Firestore onSnapshot Listeners

We are building a chat app using Firestore and React. Users should be able to up/down-vote each other's messages. We have two Firestore collections: messages: c

Why component doesn't rerender?

const [dammy, setDammy] = useState({ name: "any", status: { "1.0.1": "Successfylly installed", "1.0.2": "Successfylly installed", "1.0.3": "Succ

filter operator explained step by step

function deleteTask(id) { const remainingTasks = tasks.filter((task) => id !== task.id); setTasks(remainingTasks); } Ijust want to know in plain english, as

ReactJS push to state array replaces every exisitng value in array

I want to push an 2d array into the end of a state. But somehow, when i log the state every time it changes with a useEffect, i replaces every existing array wi

Can a React usestate update be nested in another useState functional update?

There are n items the user can vote on. There are two React states: votes is an array of the user's votes on every item. const [votes, setVotes] = useState({});

How to initialize data using map inside useState in ReactJs?

I'm new to React and in the assignment I'm working on, I have to show data in a AG Grid table. For that this is how I'm initializing rowData inside useState(),

useState hook does not update inside setTimeout function

this code must increase the "count" value gradually from 0 to 600. And each time the "count" value changes it must be logged into the console. But instead, I ge

why does this log the old value and not the new value [duplicate]

const [title,setTitle] = useState(""); const titleHandler=e => { setTitle(e.target.value) console.log(title) } Why does this code log