Greg-Bush / react-native-dimensions-hoc

A HOC to provide width and height properties with actual dimensions for your React-Native components.

Home Page:https://www.npmjs.com/package/react-native-dimensions-hoc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-dimensions-hoc

A HOC to provide width and height properties with actual dimensions for your React-Native components.

Basic Usage

import React from 'react';
import { ViewProps } from "react-native";
import withDimensions, { IDimensionsProps } from "react-native-dimensions-hoc";

export interface YourComponentProps extends ViewProps {
    ...
}

class YourComponent extends React.Component<YourComponentProps & IDimensionsProps> {

    render() {
        const { width, height, remeasure, ...viewProps } = this.props;
        return (
            <View {...viewProps} onLayout={remeasure}>
                ...
            </View>
        );
    }
    ...
}

export default withDimensions<YourComponentProps>(YourComponent);

Installation

$ npm install react-native-dimensions-hoc --save

License

MIT

About

A HOC to provide width and height properties with actual dimensions for your React-Native components.

https://www.npmjs.com/package/react-native-dimensions-hoc

License:MIT License


Languages

Language:TypeScript 100.0%