Skip to content

Instantly share code, notes, and snippets.

View nevermind89x's full-sized avatar

Francisco Montes de Oca nevermind89x

View GitHub Profile
@nevermind89x
nevermind89x / contra-suspense-code.tsx
Last active September 1, 2021 00:25
Contra Suspense Code
/**
* Working sample can be found on this link: https://codesandbox.io/s/jovial-haze-4q9fk
*
* Errors found:
* 1. First error on SuspensefulUserProfile component was the way the data is being fetched.
* This is a Fetch-on-Render approach, instead of fetching and rendering at the same time (Updated to use that one)
*
* 2. fallback prop must be set as prop on Suspense
* 3. I would add and ErrorBoundary so in case it fails thats handled
* 4. This is not an error but we could also add SuspenseList to handle the display order (still only on experiment version I think)
@nevermind89x
nevermind89x / ErrorBoundary.tsx
Created August 31, 2021 19:50
ErrorBoundary.tsx
import { Component, ErrorInfo, ReactNode } from 'react';
interface ErrorBoundaryState {
hasError: boolean;
}
interface ErrorBoundaryProps {
children: ReactNode
}