Category "reactjs"

Memoized functions to custom hook not picking up updated value from hook

Given a small hook defined as const useCount = ({ trigger }) => { const [count, setCount] = useState(1) const increment = () => setCount(count => c

React Router working on local but not work on real server

**When i try at local route is working but why not working on product ? i get 404 not found error. ** const App = () => { return ( <>

Fill treeview from custom array of objects. Recursion call

I'm using treeview to display my hierarchical data. I have following array of objects: const data = [ { id: 1, hierarchyid: "/", level: 0, name: "Mhz" },

Can anyone explain why my JavaScript map function displays two extra posts upon page refresh? Getting weird duplicates with and without errors

Hello friendly people of stackoverflow, I'm having a map function issue and I just can't put my finger on what the problem could be. Context is just for user da

Is it recommended to pass setters from useState as props?

I am currently in a coding bootcamp and the instructor told me that it is not best practice to pass the setters defined in my useState as props to children comp

Error: Can't resolve 'fs' in node_modules\dotenv\lib' in React web app

I installed dotenv using npm install --save dotenv in my React web application. Whenever I use require('dotenv') this error comes up. Error: Can't resolve 'fs'

React setState componentDidUpdate React limits the number of .. when trying to update the state based on updated state

i have react program that need the data from other components. When the parent components send path data, an array will get all of the files name inside folder,

Why React Component render many time when get event from socket.io?

I am using socket.io for my project social network web, when user connect I join, but when I get message from socket.io by group chat, My component render messa

reactive programming in react

I have a fundamental question about reactive programming in react. As you know, a react component re-renders only if one of its props changes and does not aware

State is not Setting

I am trying to store the result of my backend, which is a list of inventories, sent from my backend powered by Microsoft .Net 6 Web API. But I can't figure out

How to change the style of an element retrieved from JS getelementbyid in react?

I'm trying to target an element in the the DOM that has already been returned, and rendered, by another component; I was hoping to use a getElementById() call,

How can I expose React Hook outside of my React Functional Component

I have a React Functional Component like this: export const MyParentComponent = (props: Props) => { const [myObjects, setMyObjects = React.useState< M

(Gatsby) Easiest way to diverge from the `SEO.defaultProps` on a per-document basis?

Most of the pages on my website are in Norwegian— Seo.defaultProps = { lang: `no`, ... } Some articles, however, are in English. I use some automatic

React-query mutation dosent refresh

I have another fetch of "SpecificList in another component, but when posts excutes it dosent refetch it only refetches on rewindowfocus? What could the reason b

I get an error about "browserObject" on the console only in case of chrome in react app

I'm making an app with React. Only in Chrome, the following error is output both on localhost and after building and deploying. it is error. I did not find the

I want to display fetched data from api in form columns (auto fill data) in React.js and Mysql

i am using onKeyUp event for fire api without submitting the form and i fetched data in response successfully if Mobile number matched. But i don't understand h

Change color of Pathlayer on Click, MapBox DeckGl React.js

I have a mapbox React.js component implemented with DeckGl I am trying to make my Pathlayer color changes on evenry mouse click (onClick), using onClick, getCol

Working with promises in a React class component

I have this module to fetch data using the Spotify API: const Spotify = { getAccessToken() { ... }, searchTrack(searchTerm) { const accessToken = Spoti

I am using React Bootstrap Table and function base component and I need to save page number, size per page and text filter for reuse

I need to save page number, size per page and text filter for reuse. Suppose I'm at page 3 and text Filter is "submitted" and sizePerPage=50. Then I got to ano

Task not found: "react-scripts:start"

I've configured tailwind.css to my react project and edit the react scripts according to "scripts": { "build:css": "postcss src/styles/index.css -o src/styl