File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
frameworks/keyed/react-hooks/src Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 1
- import { memo , useReducer } from 'react' ;
1
+ import { memo , useCallback , useReducer , useTransition } from 'react' ;
2
2
import { createRoot } from 'react-dom/client' ;
3
3
4
4
const random = ( max ) => Math . round ( Math . random ( ) * 1000 ) % max ;
@@ -107,14 +107,16 @@ const Jumbotron = memo(({ dispatch }) => (
107
107
108
108
const Main = ( ) => {
109
109
const [ { data, selected } , dispatch ] = useReducer ( listReducer , initialState ) ;
110
+ const [ , startTransition ] = useTransition ( ) ;
111
+ const transitionedDispatch = useCallback ( ( ...args ) => startTransition ( ( ) => dispatch ( ...args ) ) , [ ] ) ;
110
112
111
113
return ( < div className = "container" >
112
- < Jumbotron dispatch = { dispatch } />
114
+ < Jumbotron dispatch = { transitionedDispatch } />
113
115
< table className = "table table-hover table-striped test-data" >
114
116
< tbody >
115
- { data . map ( item => (
116
- < Row key = { item . id } item = { item } selected = { selected === item . id } dispatch = { dispatch } />
117
- ) ) }
117
+ { data . map ( item => (
118
+ < Row key = { item . id } item = { item } selected = { selected === item . id } dispatch = { transitionedDispatch } />
119
+ ) ) }
118
120
</ tbody >
119
121
</ table >
120
122
< span className = "preloadicon glyphicon glyphicon-remove" aria-hidden = "true" />
You can’t perform that action at this time.
0 commit comments