I’m new to react and I need some help when I´m trying to bring some “products” from an array of objects that I have in one file of my react app called “products.js”. The thing is that I am able to draw the products within the array in the Home Screen. However when I try to draw those products on
Tag: react-hooks
global React functions that utilize hooks
I have a function called scheduleShortcut that gets used in a couple places throughout an application. Initially, this function was local to the specific components but since it is being used multiple times, I want to refactor this function into a global function. At first, I tried to do the following: However, when I do this, I get an error
React Hooks useState array storage problem
I have the following problem: I have a method that returns a multidimensional array in my Grids component. I would want to store any multidimensional array recomputed in a separate list. The problem is that when I am using my useState() declared in this way only the current state element is saved repeatedly in the array list. Follow the code
React JS sorting issue
I’m trying to sort some data in my application. I’d like to support the following options: Price (low to high) Price (high to low) Mileage (low to high) Mileage (high to low) It looks like price sorting is working. However, when I click on “lowest mileage”, it keeps showing the highest price results – the old value of sorting. I
React connecting info between App.js and a class
I am trying to integrate React Scheduler into my app that uses JSON data base. how can I pass the shifts and functions defined in App.js that update the data to DataSheet.js and use them instead of the defaults? Is there a better way to enable the database update from the DataSheet? App.js: DataSheet.js: Answer Pass the data as props
How to fix React.useEffect and useCallback circular loop when updating a state?
I’m fetching some data from an API, but since I am using this data to update a state within a useEffect, this state becomes a required dependency, which causes a circular loop. state is updated -> useEffect is called -> state is updated … I read a lot of answers and articles about that, but I couldn’t find an answer
Loop through array of objects and display them in react component
I have an array of object as follows. The data is based on created_date for e.g. (“2021-09-12”) As you can see, i have got last 5 days of data. i.e. 12th Sep, 11th Sep, 10th Sep, 9th Sep and 8th Sep. The response does not have any data for 11th sept and 8th Sept. Based on this above information, i
Next.js context provider wrapping App component with page specific layout component giving undefined data
I have an auth context component where I’m wrapping my main app component, but at the same time I’m also trying to do page specific layout component per Next.js documentation here: https://nextjs.org/docs/basic-features/layouts#per-page-layouts Am I doing this correctly, because I can’t seem to be getting the data from my Context provider. /context/AuthContext.js /_app.js /components/Project/List.js I’m trying to console log the user,
Disabled When Lacking Input in Field in React
I have set of inputs that needs to be filled out completely. I should disable the submit button when its not complete. Its working fine until I decided to erase and fill it out again. It never disables. What would be the proper and correct way to do this? Is there a better way to do this? CLICK HERE Answer
useEffect doesn’t fire when data change
I created a table with filter. every thing worked well. Later on, I wanted to change the filters from material ui to Core ui. I created one filter and tried to test it before moving. But it didn’t work. The problem that useEffect doesn’t fire no matter what. I even tried to put variable x and increment it when a