import React, { lazy, Suspense, useState, useEffect } from 'react';
// 1. Component lazy loading
const HeavyComponent = lazy(() => import('./HeavyComponent'));
const AdminPanel = lazy(() => import('./AdminPanel'));
const Dashboard = lazy(() => import('./Dashboard'));
import React, { useState, useEffect, useCallback, useMemo, useRef, useContext } from 'react';
// 1. useState - managing component state
function Counter() {
const [count, setCount] = useState(0);
const [name, setName] = useState('');
export const initialState = (steps, initialData = {}) => ({
steps,
stepIndex: 0,
data: initialData,
errors: {},
});
import { ReactNode, useEffect, useState } from 'react'
import { createPortal } from 'react-dom'
interface PortalProps {
children: ReactNode
container?: Element
import { Link, useLocation, useMatches } from 'react-router-dom'
interface BreadcrumbMatch {
pathname: string
handle?: {
crumb?: (data?: any) => string
export interface Todo {
id: string;
title: string;
done: boolean;
}
import React, { createContext, useContext, useState, ReactNode } from 'react'
interface TabsContextType {
activeTab: string
setActiveTab: (tab: string) => void
}
import { createContext } from "react";
export type ToastVariant = "info" | "success" | "error";
export interface Toast {
id: string;
import { useState, useRef, useEffect, useCallback } from "react";
export function useCarousel(length, { delay = 4000 } = {}) {
const [index, setIndex] = useState(0);
const [paused, setPaused] = useState(false);
const savedCallback = useRef(null);
const { EventEmitter } = require('events');
class NotificationBus extends EventEmitter {
constructor(bufferSize = 100) {
super();
this.setMaxListeners(0);
export class TimeoutError extends Error {
constructor(public readonly ms: number) {
super(`Request timed out after ${ms}ms`);
this.name = "TimeoutError";
}
}
import { Link } from 'react-router-dom'
import { useQueryClient } from '@tanstack/react-query'
import api from '@/services/api'
import { PostId } from '@/types'
interface PostLinkProps {