Skip to content

Instantly share code, notes, and snippets.

View sriram-palanisamy-hat's full-sized avatar

Sriram-palaniswamy-hat sriram-palanisamy-hat

  • Hash Agile
  • India
  • 18:49 (UTC +05:30)
View GitHub Profile
  • What's a suspense boundary and what it does when throws a promise?
    • import { Suspense } from 'react';
      import Albums from './Albums.js';
      
      export default function ArtistPage({ artist }) {
        return (
          <>
            <h1>{artist.name}</h1>
            <Suspense fallback={<Loading />}>
      
@sriram-palanisamy-hat
sriram-palanisamy-hat / useHover.jsx
Created October 26, 2025 15:26
Create a useHover() hook
import { useState, useRef, useEffect } from "react";
export function useHover<T extends HTMLElement>() {
const [isHovered, setIsHovered] = useState(false);
const ref = useRef<T | null>(null);
useEffect(() => {
const node = ref.current;
if (!node) return;
@sriram-palanisamy-hat
sriram-palanisamy-hat / ErrorBoundaryTest.jsx
Created October 26, 2025 15:22
Which Error Boundary catches the error
import * as React from 'react';
function App() {
return (
<ErrorBoundary name="boundary-1">
<A />
</ErrorBoundary>
)
@sriram-palanisamy-hat
sriram-palanisamy-hat / SuspenseTest.jsx
Created October 26, 2025 15:21
What's a suspense boundary and what it does when throws a promise?
import { Suspense } from 'react';
import Albums from './Albums.js';
export default function ArtistPage({ artist }) {
return (
<>
<h1>{artist.name}</h1>
<Suspense fallback={<Loading />}>
<Albums artistId={artist.id} />
</Suspense>