Questions tagged [react-suspense]

194 questions
1
vote
0 answers

Do we need to throw the same promise every time in react suspense

When fetching data in the body of a functional component, the expression should evaluate either to a thrown promise or the response value, if I understand correctly. Does Suspense need the same promise to be thrown each time or just any promise? Is…
0
votes
0 answers

How can I introduce a buffer to React-leaflet?

I'm currently using React-leaflet to plot and pinpoint data. However, I have a massive amount of data to display, so I'm trying to introduce a buffer using Lazy, Suspense or Loadable. But when I structure it with React-leaflet in Map.js and then try…
0
votes
0 answers

Nextjs13 revalidateTag Loading Modal while waiting for revalidation

Got a quick question for you. I'm working on a Next.js frontend app hooked up to a Flask backend. So, I'm triggering a server action when a button is clicked, using the startTransition() function. That action includes a revalidateTag once the data…
0
votes
0 answers

Questions about useQuery and react-error-boundary package

I want to use the react-error-bounary package and suspense to handle asynchronous handling in the asynchronous processing method using isLoading and isError, which are normally operating in useQuery. The code below is the code using the…
0
votes
1 answer

Suspense fallback same as lazy load children

Const A = lazy(() => import(“compA”)) render() { } } I want B to be loaded while A is resolving. But fallback unmounts B and is mounted again when A…
macro
  • 31
  • 1
  • 1
  • 4
0
votes
1 answer

Trying to implement React Suspense boundary and refetching data from API after some events

Hey im pretty new to React and JS. Im trying to implement the React Suspense boundary for a component that requires fechting data from my backend API. I used the fetchData and wrapPromise function from this example…
lexer
  • 1
  • 2
0
votes
0 answers

How to test component that uses lazy imported @mui/material components?

I have a footer component that simply returns the BottomNavigation and BottomNavigationAction components. I am bringing these into my component lazily, but I can't seem to unit test these successfully... I am using react-test-renderer and…
physicsboy
  • 5,656
  • 17
  • 70
  • 119
0
votes
1 answer

Why does React.createPortal allow key like list items, whereas other things like doesn't?

I have seen some apis in ReactJs to allow keys, e.g. , but at the same time doesn't have keys. Now specifically why does React.createPortal allow key like list items? My research: I didn't find much on SO or google,…
user31782
  • 7,087
  • 14
  • 68
  • 143
0
votes
1 answer

React infinite re-renders using nextjs latest

I am using latest Next.js app router version. When I load data in my component it initially renders infinite I don't know why. I have valid data. SidebarContent.tsx "use client"; import { useEffect, useState } from "react"; import SlidebarItems from…
Bidhanz
  • 3
  • 1
0
votes
0 answers

Is it possible to have Suspense await a useFetch on a different React component?

I'm trying to suspend and lazy load multiple components which have cross-dependencies. I cannot figure out how to ensure one suspended component awaits the other before attempting to load. My scenario is as follows, I have a component called…
Tim
  • 3
  • 3
0
votes
1 answer

How to test a React Suspense 'promise wrapper' in Jest, when fetching data via axios

I'm trying to update my useAxios hook to work with React Suspense, following this guide: https://deadsimplechat.com/blog/react-suspense/ const promiseWrapper = (promise: Promise) => { let status = 'pending'; let result: any; const…
C A Mc
  • 449
  • 1
  • 4
  • 7
0
votes
0 answers

React Suspense is not showing fallback second time component renders

I am doing some heavy operations inside field component and it is taking some time to render the component. So i am using react suspense to show loader. When i turn on editMode first time, able to see fallback. but after first time if i turn on edit…
0
votes
0 answers

React Error Boundary doesn't catch runtime error

My code looks like this: const routes = ( ); ReactDOM.render(
Gambit2007
  • 3,260
  • 13
  • 46
  • 86
0
votes
0 answers

Why doesn't react suspense work properly with redux toolkit query?

I have a component that use redux toolkit query useGetUserQuery('id') and loading state is handled with isLoading property but I hear that suspense is better for showing a loading screen when requesting an async data. first, is that true ? second, I…
0
votes
0 answers

Why am I getting a 'connection closed' error when using NextJS 13.4's streaming feature with React Suspense?

Error Image THE ABOVE ERROR OCCURS when I tried to load more than two data with suspense (streaming). I'm using Next JS 13.4 with App router by the way. export const serverApi = async ( url: string, init?: RequestInit ): Promise => { …