Skip to content

A component for getting the dimensions of a view in React Native

Notifications You must be signed in to change notification settings

shichongrui/react-native-on-layout

Repository files navigation

react-native-on-layout

Having to get a components rendered dimensions is a pretty common pattern in React Native and this is a component that makes doing so easy.

import OnLayout from 'react-native-on-layout'

<OnLayout>
    {({ width, height}) => (
        <Text>{width} {height}</text>
    )}
</OnLayout>

OnLayout renders a View component to do onLayout so you can pass any View prop to OnLayout and it will pass them as props to the rendered View component.

About

A component for getting the dimensions of a view in React Native

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published