File tree Expand file tree Collapse file tree 4 files changed +12
-2
lines changed
react/core/08-rendering-performance/useTransition Expand file tree Collapse file tree 4 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -6,16 +6,26 @@ import { Heading } from '~/Heading'
6
6
// https://github.com/reactwg/react-18/discussions/41
7
7
// https://vercel.com/blog/how-react-18-improves-application-performance
8
8
9
+ console . time ( )
10
+ setTimeout ( ( ) => {
11
+ console . timeEnd ( )
12
+ } , 1000 )
13
+
9
14
export function BrowseUsers ( ) {
10
- const allUsers = useUsers ( 1000 ) // generate 1000 user objects with random "likes"
15
+ const allUsers = useUsers ( 100 ) // generate 100 user objects with random "likes"
11
16
12
17
const [ users , setUsers ] = useState ( allUsers )
13
18
const [ minLikes , setMinLikes ] = useState ( 0 )
14
19
15
20
// const [pending, startTransition] = useTransition()
16
21
function filterUsers ( minLikes : number ) {
17
22
setMinLikes ( minLikes )
18
- setUsers ( allUsers ?. filter ( ( u ) => u . likes >= minLikes ) )
23
+
24
+ console . time ( )
25
+ const filteredUsers = allUsers ?. filter ( ( u ) => u . likes >= minLikes )
26
+ console . timeEnd ( )
27
+
28
+ // setUsers(filteredUsers)
19
29
}
20
30
21
31
const editUser = ( userId : number ) => {
File renamed without changes.
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments