Unblock React Compiler for 4 components with deferred ref access (#11549)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {useRef, useState} from 'react'
|
||||
import {useEffect, useRef, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import PagerView from 'react-native-pager-view'
|
||||
import {type PagerViewOnPageSelectedEvent} from 'react-native-pager-view'
|
||||
@@ -26,9 +26,17 @@ export function ValuePropositionPager({
|
||||
|
||||
if (step !== activePage) {
|
||||
setActivePage(step)
|
||||
ref.current?.setPage(step)
|
||||
}
|
||||
|
||||
/*
|
||||
* In an effect rather than inline above: driving the pager is a side effect,
|
||||
* and reading a ref during render is a Rules of React violation. `initialPage`
|
||||
* already covers the first render, so the mount run is a no-op.
|
||||
*/
|
||||
useEffect(() => {
|
||||
ref.current?.setPage(step)
|
||||
}, [step])
|
||||
|
||||
const images = [PROP_1[t.name], PROP_2[t.name], PROP_3[t.name]]
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user