1.0.5 • Published 5 years ago

react-native-use-unit v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

The package contains only one function that is a hook. The creates unit convter.

That converts css units as string (the supported units are, px, rem, vh, vw, vmin and vmax) value to pixels representing numbers.

The rem value can be set with a RemProvider Component, the default value is 16px.

import { useInitUnitConverter, RemProvider } from "react-native-use-unit";

const App: React.FC = () => {

    const unit = useInitUnitConverter();

    return (
        <>
            <View
            style={{
                backgroundColor: "red",
                width: unit("50vw"),
                height: unit("50vh"),
                marginLeft: unit("25vw"),
                marginTop: unit("25vh"),
                paddingBottom: unit("8rem")
            }}/>

            <RemProvider
            value={8}>
                <View
                style={{
                    padding: unit("16rem")
                }}/>
            </RemProvider>
        </>
    );
};
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago