Skip to content
Advertisement

Tag: reactjs

Jest test: Cannot find module, in typescript component import

The path to my styled objects is correct, however not sure why I’m getting the following error: Cannot find module ‘../../shared/models’ from ‘Astronaut.tsx’ import { moonHoldings } from ‘../../shared/models’; My simple Jest test: The Astronaut component The Jest config section of my Package.json And my folder structure: Answer Ok I just fixed this by created an index file inside of

React suspense/lazy delay?

I am trying to use the new React Lazy and Suspense to create a fallback loading component. This works great, but the fallback is showing only a few ms. Is there a way to add an additional delay or minimum time, so I can show animations from this component before the next component is rendered? Lazy import now Waiting component:

Material-UI: Uncaught RangeError: Maximum call stack size exceeded

I’m using the Dialog and Select components from Material-UI and React. Just an example: After clicking on the select, i’m getting this error from Modal.js: “Uncaught RangeError: Maximum call stack size exceeded. at HTMLDocument.Modal._this.enforceFocus (Modal.js?86a5:197)” Any ideas? Answer Add the prop disableEnforceFocus to the Dialog component. Reference: issues/10341

Is it okay to call onClick on an anchor tag in ReactJS

Folks, I have an anchor tag inside my component like so: I want to call an analytics function when user clicks on this tag like so: Notice that I’m not setting state or calling any of the react functions. Is it okay if I just call a function on the onClick event of the anchor tag? Something like this: with

react useEffect comparing objects

I am using react useEffect hooks and checking if an object has changed and only then run the hook again. My code looks like this. Unfortunately it keeps running as the objects are not being recognised as being the same. I believe the following is an example of why. Perhaps running JSON.stringify(apiOptions) works? Answer Use apiOptions as state value I’m

Advertisement