I want the hover functionality to happen (UI) which is happening in this case: Desired UI Source: https://www.loewshotels.com/santa-monica Now since modifying background image styles is a bit complicated, I have to use the Box Component from Material UI and in it, I have placed the image and also done the des…
Tag: reactjs
Where am I going wrong with returning an array from a react function [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 y…
Data fetched and set with setState inside useeffect doesnt appear in console log unless i set a timeout
So I am fetching data from my database for each item in the array groups and then I want to map through this data (twice because it’s an array inside an array) in the jsx part of the component. The problem though is that the state is changed “too late” This is my guess because the console lo…
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: Howeve…
React: Converting mongoDB date to human readable date
A document stored in MongoDB has a “createdAt” property, which contains a timestamp. Here we have an example of the timestamp: Considering this date is today, how can I reproduce the following behavior?: Display this date as “Today at 12:24 PM” Tomorrow, display this date as “Yes…
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 i…
How to store the value of a variable in state immediately when set state is async
I am new to react and am trying to store the value in state for customer my code for getting the value of the dropdown is this: I am running function this.getCustomerName() in this function, The code for that is this: I am setting code= this.state.customer in the function getCustomerName which I am running ju…
react – state undefined when passing child state through parent
I’m trying to learn react and ran into a snag. I’m struggling to update the parent based on the child state. I’ve managed to pass the child state to the parent by binding the child’s state to the same child’s prop when invoked by the parent. Parent.js Child.js The console keeps r…
How to avoid a child div in react invoking a parent’s `onDragLeave` event
Please see this codesandbox. I have a parent div that needs to handle for draggable events (such as when a file is dragged over it). When onDragEnter is invoked, I want the background color to change. However, I have a child div, which, when hovering over it, invokes the parent div’s onDragLeave event. …
Module not found: Can’t resolve ‘@mui/icons-material/FileDownload’
I have installed both @material-ui/core and @material-ui/icons. I am trying to import “FileDownloadIcon” from Material icons. Installing “@material-ui/core”: Installing “@material-ui/icons”: This is the way I am trying to import “FileDownloadIcon”: But it’…