easy-ref-merge
v0.0.2
Published
easy ref merge is a react/react-native package that helps you to merge more than one reference and inject them to the same component
Downloads
3
Maintainers
Readme
:iphone: Easy Ref Merge :fist:
:blue_book: Description
:boom: ShowCase
:zap: Installation
:key: Usage
:page_facing_up: Examples
:ok_hand: Why easy-ref-merge ?
Description
easy ref merge is a react/react-native package that helps you to merge more than one reference and inject them into the same component.
Installation
#npm
npm install easy-ref-merge
#yarn
yarn add easy-ref-merge
Usage
We have only one function
- refsMerge its called with any number of references and produce single merged reference.
Package Import :
import refsMerge from "easy-ref-merge";
Examples
./OuterWrapper.js
import InnerWrapper from "./InnerWrapper.js";
import React, { useRef } from "react";
const OuterWrapper = () => {
const ref = useRef();
return <InnerWrapper ref={ref} />;
};
./InnerWrapper.js
import React from "react";
import { Text } from "react-native";
import refsMerge from "easy-ref-merge";
const InnerWrapper = React.forwardRef((props, ref) => {
const localRef = useRef(/*a reference generated for special purpose*/);
return <Text ref={refsMerge(localRef, ref)}>Easy Ref Merge</Text>;
}, []);
Why easy-ref-merge ?
- :heavy_check_mark: small size package :muscle:
- :heavy_check_mark: easy to use :muscle:
- :heavy_check_mark: allows you to merge any number of references :muscle: