import React, { lazy, Suspense } from 'react'; import Counter from './Counter';
import React from 'react';
import React, { lazy, Suspense } from 'react'; import './App.css'; import Counter from './Counter'; code mosh react 18 beginners fco better
export default App; To see automatic batching in action, you can modify Counter.tsx to include a function that updates state and then uses fetch to make an API call:
import React, { useState } from 'react'; import React, { lazy, Suspense } from 'react';
const LazyLoadedComponent = lazy(() => import('./LazyLoadedComponent'));
const Counter = () => { const [count, setCount] = useState(0); Suspense } from 'react'
const LazyLoadedComponent = () => { return <div>This component was lazy loaded!</div>; };