Skip to content

Commit

Permalink
[v9] chore: replace forwardRef with props.ref (#3282)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandernanberg authored Jan 10, 2025
1 parent f3edadb commit b3e4ee4
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 246 deletions.
34 changes: 16 additions & 18 deletions packages/fiber/__mocks__/react-native.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import * as React from 'react'
import { ViewProps, LayoutChangeEvent } from 'react-native'
import { ViewProps, LayoutChangeEvent, View as RNView } from 'react-native'

// Mocks a View or container as React sees it
const Container = React.memo(
React.forwardRef(({ onLayout, ...props }: ViewProps, ref) => {
React.useLayoutEffect(() => {
onLayout?.({
nativeEvent: {
layout: {
x: 0,
y: 0,
width: 1280,
height: 800,
},
const Container = React.memo(({ onLayout, ...props }: ViewProps) => {
React.useLayoutEffect(() => {
onLayout?.({
nativeEvent: {
layout: {
x: 0,
y: 0,
width: 1280,
height: 800,
},
} as LayoutChangeEvent)
}, [onLayout])
},
} as LayoutChangeEvent)
}, [onLayout])

React.useImperativeHandle(ref, () => props)
// React.useImperativeHandle(ref, () => props)

return null
}),
)
return null
})

export const View = Container
export const Pressable = Container
Expand Down
Loading

0 comments on commit b3e4ee4

Please sign in to comment.