Skip to main content
Advice
1 vote
5 replies
95 views

I’m currently working on a React project and I’m trying to determine when to use useState (i.e., local state) versus introducing Redux for managing state. While I understand that Redux can be powerful ...
Arjee Zen's user avatar
0 votes
3 answers
225 views

Illustrative example: export const App = () => { const [things, setThings] = useStoredState(window.localStorage, 'things', [ { id: 0, name: 'New Thing' }, ]); const [selectedThingId, ...
Thom Smith's user avatar
  • 14.2k
-1 votes
1 answer
52 views

Imagine a React Component like this with two states, each can be updated with the click of a button: The object-like state foo with the update function setFoo The number state bar with the update ...
jrasko's user avatar
  • 21
2 votes
2 answers
101 views

This is the hook I use to activate the navbar item when its section is visible in the screen, for example: section with id "#howtoorder" is in the visible part of the screen, then the navbar ...
seventeen's user avatar
Best practices
1 vote
5 replies
122 views

So, being used other reactive frameworks I'm now starting to learn and work with React. I'm building a simple exercise and I'm struggling with the way State is managed in React, I'll already have ...
Noel Rubio Lavilla's user avatar
0 votes
2 answers
171 views

Here are two React components: function MainScreen() { const [stopwatches, setStopwatches] = useState([ new Stopwatch('A'), new Stopwatch('B') ]); const [selectedStopwatchIndex, ...
eric's user avatar
  • 31
2 votes
1 answer
118 views

The below block of code works. Component rerenders when state changes from parent (MainBox) export function MainBox(){ const [valuestate, setvalueState] = useState() return( <div&...
Coffee's user avatar
  • 37
3 votes
2 answers
252 views

Ref interface: // create const count = useRef(0); // update (does not trigger render) count.current = 5; // access console.log(count.current); State variable interface: //create const [count, ...
Always a Newb at Something's user avatar
0 votes
1 answer
95 views

I'm trying to write a custom React hook that fetches data. It seems to work partially — but loading goes false before data is set, and error is never set even when a request fails. import { useState, ...
Work Profession's user avatar
-1 votes
2 answers
86 views

I am trying to build a custom form component. In this I use inertiajs useForm hook to automatically load the data into a state (similar to react-use-form). But my problem is, that everytime i type a ...
Henry's user avatar
  • 1
0 votes
2 answers
83 views

perms is an array of objects. Each object is: { catg: 'Catg1' serv: ->array of serv objects { checked: false, desc: 'Serv 1' } } On button click, based on ...
DavidC's user avatar
  • 195
-1 votes
1 answer
53 views

I have a parent component where I use state to control the visibility of a child component. If I use a button to open a modal it works, but when I change the state in useEffect child prop = false ...
Алексей Смирнов's user avatar
2 votes
1 answer
79 views

In my React Native app, I'm having a problem where the setState function is not being recognized as a function. I already inserted the context provider on the App root page and exported the context ...
Vivantt's user avatar
  • 43
-1 votes
1 answer
60 views

I try to make some kind of infinite scroll Here is my CodeSandbox setup (first approach) To paginate I made some kind of cursor which keeps last loaded item id in after state variable I use that after ...
bankangle's user avatar
  • 129
0 votes
1 answer
1k views

I'm trying to compose my own Combobox component using Shadcn ui. In doing this I am using the Command component. I am trying to bind my command input value to React state in Next.js client component ...
Ethan's user avatar
  • 1,918

15 30 50 per page
1
2 3 4 5
88