648 questions
0
votes
0
answers
14
views
How to get React Native Pressable component to use correct state for onPressOut
I would like to change the onPressOut field from React Native's Pressable component based on the state I pass in. But when I log it, it keeps giving me stale state and I'm not sure why. I would expect ...
1
vote
1
answer
286
views
React flow switching handle types not working
I am trying to make a button on a react flow node that switches the type of the handles (target or source) and it does not work. In the devtools i can see that the handles ares switching types, but ...
0
votes
1
answer
32
views
Issue with Retaining Current Topic on Page Refresh in React
I’m building a programming tutorial website using React. Each content page has a sidebar and a main content section with "Previous" and "Next" buttons to navigate topics. However, ...
-1
votes
2
answers
109
views
React js state management if-else condition
What is difference in writing in two different ways below?
function App(isTrue){
if(isTrue)
return <ComponentA/>
else
return <ComponentB/>
}
// what is different if I write ...
1
vote
2
answers
91
views
Data inconsistency
I am studying Front end development and am writing simple shopping cart in React to learn. When I change product quantity I want to create an object of quantity values by product id and pass them to ...
1
vote
1
answer
67
views
Extracting and aggregating a state of lower components / Avoiding rendering
I have a question regarding react state. I'm still a beginner but - I have a table with three columns. In two of these, I have input fields. I set it up each row is a component and has its own state. ...
0
votes
1
answer
90
views
Avoiding endless event listeners that are added when a state changes in React
I have a state-variable items that's just a collection (object) of items with an ID and a ref (which points to an HTMLDivElement), and a state-variable attachments which is another collection, but has ...
-1
votes
2
answers
52
views
Why RecatJS do not update value when it changes
I`m learning React and I do not understand - why in first render React generate correctly value playerSymbol, but when It changes it is not re-render even when gameBoard changes. Code:
import { ...
0
votes
1
answer
60
views
Retaining selected image state on closePopup in React component
I'm encountering an issue with a React component where I'm implementing functionality to upload images. When the user selects an image using the file input, the selected image is displayed within a ...
0
votes
0
answers
23
views
Is it possible to add a transition animation effect after the state changes in React
I need to apply a sliding animation effect to a new thumbnail loaded in the slider.
I am unable to figure out how this can be acheived in React. Do I need to use CSS or can it be achieved with ReactJS ...
-2
votes
2
answers
128
views
React JS - state management [closed]
I have been learning React recently, I tried to build a small web-app for learning React. I have doubt regarding the state management.
I am not using anying library for state management now and also I ...
0
votes
0
answers
35
views
REACT - sharing data between siblings causes main app to re-render
First of all, I'm learning react and never post anything here.
Sorry if I sound confusing, cuz I really am...
I have the following project using Functional Components:
APP(Parent)
|---- Header (...
1
vote
1
answer
56
views
Unable to force render Context in React
I'm working on a React application that features a complex, multiple-page form. The form's data is managed through a context, where each page has its own set of state variables. One challenge I'm ...
2
votes
1
answer
95
views
React Form UI Not Reflecting State Changes Correctly
I'm working on a nested form in React where a user can have multiple forms, each form can have multiple sections, and each section can have multiple dropdowns. I'm facing an issue where removing a ...
-1
votes
2
answers
45
views
How to update the state element properly in react js?
import React, { useState } from "react";
import Form from "./child/form.js";
import Details from "./child/details.js";
function App() {
const [inp, modifyInp] = useState(...
0
votes
3
answers
98
views
React useState callback function not re-rnder DOM
I have a page for listing products in a table, each row of the table has checkbox who meant to toggle the row's active (Boolean) state when it clicked. The problem is that after updating the state the ...
1
vote
1
answer
559
views
How do I manage the complex state of a list of components? (Nextjs/ReactJS)
I have a form that I use to create a new recipe with. This form contains a list of ingredients a user can add to and delete from.
It looks like this:
I have an Ingredient Component which is just the ...
5
votes
2
answers
2k
views
How to use Context API in Next JS 13 with server-side components?
Is it possible in Next JS 13 to fetch data on the server but then propagate it to Context API?
In my case, I want to fetch user information via token on the server, but then pass it to Context API ...
0
votes
1
answer
315
views
Managing state when using multiple child components
I am not an expert in react. My problem statement is that
I have a main component which in turn renders multiple child components for specific functions
Now, when I save the main component , I want ...
0
votes
1
answer
274
views
Fetching value from another Redux slice as initial state in a different slice
I have two Redux slices in my application: userSlice and cartSlice. I would like to fetch a specific value (userName) from the userSlice and assign it as the initial value for a property (user) in the ...
0
votes
1
answer
2k
views
How to avoid re-render in RTK query?
This is my RTK query code for social media website but the problem I found is that when I click like , post a comment , and post a reply to comment , delete , update a particular post , then all ...
0
votes
1
answer
453
views
From "Add To Cart" to "Added To Cart"
How to change from "Add To Cart" to "Added To Cart" in react.js on clicking the "Add To Cart" button?
Here is my "Add To Cart" button.
<button
className=&...
0
votes
2
answers
1k
views
How to solve Race condition in setting React state?
I have component that have state as object
const [data, setData] = useState({
input,
output: '',
enableCopyToClipboard: true,
}
When listen to Observable I do following:
// reset state ...
2
votes
1
answer
53
views
Updating the child component from parent component
I have an array in parent component with some values 'name', i want to render the items in the child component based on the matching value from an array with same value 'name'. Like when user clicks ...
0
votes
1
answer
451
views
React handleClose() function logging to console but not closing child element
So I'm trying to make a small online store for a personal business.
I'm not very good with React, but I feel like I've made some headway and might be able to finish something at least functional, if ...