1.1.4 • Published 4 years ago
rn-responsive-lite v1.1.4
Installation
Installation is done using the
npm install
command:
npm install rn-responsive-lite
Pre-usage Setup
- Import rnrsp in your main root file.But not in index.js(any root file after index.js)
import {rnrsp} from 'rn-responsive-lite';
- Initialize all the required variables.
const {height, width} = Dimensions.get('window')
rnrsp.init(height,width);
Refer to the below demo snippet of main file. Here my main component is named as Main and file Main.js.
import React, { Component } from 'react';
import { Dimensions } from 'react-native';
const {height, width} = Dimensions.get('window')
/*
* Initialize all states or global variables you need
*/
rnrsp.init(height,width);
export default class Main extends Component {
constructor(props) {
super(props);
this.state = {
};
}
componentDidMount(){
}
componentWillUnmount() {
}
render() {
return (
<Text style={{height: rnrsp.height(50)}}>My clild components here.</Text>
);
}
}
Usage
- Responsive Height.
rnrsp.height(value)
- Responsive Width.
rnrsp.width(value)
- Responsive Height Percentage.
rnrsp.heightp(value)
- Responsive Width Percentage.
rnrsp.widthp(value)
- Responsive Fontsize.
rnrsp.fontsize(value)
- Responsive Elements like square circle whose height and width is equal.
rnrsp.allround(value)