Skip to content

Commit

Permalink
Migrate to props.ref
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandernanberg committed Jan 4, 2025
1 parent 94b4e6c commit 7a76b8c
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 7a76b8c

Please sign in to comment.