@@ -31,24 +31,16 @@ function SuspenseTimelineInput() {
3131 const { highlightHostInstance, clearHighlightHostInstance} =
3232 useHighlightHostInstance ( ) ;
3333
34- const {
35- selectedRootID : rootID ,
36- timeline,
37- timelineIndex,
38- uniqueSuspendersOnly,
39- } = useContext ( SuspenseTreeStateContext ) ;
34+ const { timeline, timelineIndex, uniqueSuspendersOnly} = useContext (
35+ SuspenseTreeStateContext ,
36+ ) ;
4037
4138 function handleToggleUniqueSuspenders ( event : SyntheticEvent ) {
4239 const nextUniqueSuspendersOnly = ( event . currentTarget as HTMLInputElement )
4340 . checked ;
44- const nextTimeline =
45- rootID === null
46- ? [ ]
47- : // TODO: Handle different timeline modes (e.g. random order)
48- store . getSuspendableDocumentOrderSuspense (
49- rootID ,
50- nextUniqueSuspendersOnly ,
51- ) ;
41+ const nextTimeline = store . getSuspendableDocumentOrderSuspense (
42+ nextUniqueSuspendersOnly ,
43+ ) ;
5244 suspenseTreeDispatch ( {
5345 type : 'SET_SUSPENSE_TIMELINE' ,
5446 payload : [ nextTimeline , null , nextUniqueSuspendersOnly ] ,
@@ -81,24 +73,10 @@ function SuspenseTimelineInput() {
8173 const min = 0 ;
8274 const max = timeline . length > 0 ? timeline . length - 1 : 0 ;
8375
84- if ( rootID === null ) {
85- return (
86- < div className = { styles . SuspenseTimelineInput } > No root selected.</ div >
87- ) ;
88- }
89-
90- if ( ! store . supportsTogglingSuspense ( rootID ) ) {
91- return (
92- < div className = { styles . SuspenseTimelineInput } >
93- Can't step through Suspense in production apps.
94- </ div >
95- ) ;
96- }
97-
9876 if ( timeline . length === 0 ) {
9977 return (
10078 < div className = { styles . SuspenseTimelineInput } >
101- Root contains no Suspense nodes .
79+ Timeline contains no suspendable boundaries .
10280 </ div >
10381 ) ;
10482 }
@@ -117,23 +95,10 @@ function SuspenseTimelineInput() {
11795 }
11896
11997 function handleChange ( event : SyntheticEvent ) {
120- if ( rootID === null ) {
121- return ;
122- }
123- const rendererID = store . getRendererIDForElement ( rootID ) ;
124- if ( rendererID === null ) {
125- console . error (
126- `No renderer ID found for root element ${ rootID } in suspense timeline.` ,
127- ) ;
128- return ;
129- }
130-
13198 const pendingTimelineIndex = + event . currentTarget . value ;
13299 const suspendedSet = timeline . slice ( pendingTimelineIndex ) ;
133100
134101 bridge . send ( 'overrideSuspenseMilestone' , {
135- rendererID,
136- rootID,
137102 suspendedSet,
138103 } ) ;
139104
@@ -202,57 +167,9 @@ function SuspenseTimelineInput() {
202167}
203168
204169export default function SuspenseTimeline ( ) : React$Node {
205- const store = useContext ( StoreContext ) ;
206- const { roots, selectedRootID, uniqueSuspendersOnly} = useContext (
207- SuspenseTreeStateContext ,
208- ) ;
209- const treeDispatch = useContext ( TreeDispatcherContext ) ;
210- const suspenseTreeDispatch = useContext ( SuspenseTreeDispatcherContext ) ;
211-
212- function handleChange ( event : SyntheticEvent ) {
213- const newRootID = + event . currentTarget . value ;
214- // TODO: scrollIntoView both suspense rects and host instance.
215- const nextTimeline = store . getSuspendableDocumentOrderSuspense (
216- newRootID ,
217- uniqueSuspendersOnly ,
218- ) ;
219- suspenseTreeDispatch ( {
220- type : 'SET_SUSPENSE_TIMELINE' ,
221- payload : [ nextTimeline , newRootID , uniqueSuspendersOnly ] ,
222- } ) ;
223- if ( nextTimeline . length > 0 ) {
224- const milestone = nextTimeline [ nextTimeline . length - 1 ] ;
225- treeDispatch ( { type : 'SELECT_ELEMENT_BY_ID' , payload : milestone } ) ;
226- }
227- }
228-
229170 return (
230171 < div className = { styles . SuspenseTimelineContainer } >
231- < SuspenseTimelineInput key = { selectedRootID } />
232- { roots . length > 0 && (
233- < select
234- aria-label = "Select Suspense Root"
235- className = { styles . SuspenseTimelineRootSwitcher }
236- onChange = { handleChange }
237- value = { selectedRootID === null ? - 1 : selectedRootID } >
238- < option disabled = { true } value = { - 1 } >
239- ----
240- </ option >
241- { roots . map ( rootID => {
242- // TODO: Use name
243- const name = '#' + rootID ;
244- // TODO: Highlight host on hover
245- return (
246- < option
247- key = { rootID }
248- value = { rootID }
249- disabled = { ! store . supportsSuspenseTree ( rootID ) } >
250- { name }
251- </ option >
252- ) ;
253- } ) }
254- </ select >
255- ) }
172+ < SuspenseTimelineInput />
256173 </ div >
257174 ) ;
258175}
0 commit comments