Skip to content

Repository files navigation

react-native-replace-selected

Library provides native method for replacing selected text in TextInput with a new text

Installation

npm install -S react-native-replace-selected
yarn add react-native-replace-selected

Usage

import{replaceSelected}from'react-native-replace-selected';replaceSelected(textInputRef.current,"new text");
importReact,{useState,useRef}from'react';import{StyleSheet,View,Button,TextInput}from'react-native';import{useReplaceSelected}from'react-native-replace-selected';exportdefaultfunctionApp(){const[text,setText]=useState('Example Text');consttextInputRef=useRef<TextInput>(null);constreplaceSelected=useReplaceSelected(textInputRef);constreplaceText=()=>replaceSelected('😀');return(<View><TextInputref={textInputRef}onChangeText={setText}value={text}/><Buttontitle="Replace selected text with 😀"onPress={replaceText}/></View>);}
importReact,{useState,useRef}from'react';import{StyleSheet,View,Button,TextInput}from'react-native';import{replaceSelected}from'react-native-replace-selected';exportdefaultfunctionApp(){const[text,setText]=useState('Example Text');consttextInputRef=useRef<TextInput>(null);constreplaceText=()=>{if(!textInputRef.current)return;replaceSelected(textInputRef.current,'😀');};return(<View><TextInputref={textInputRef}onChangeText={setText}value={text}/><Buttontitle="Replace selected text with 😀"onPress={replaceText}/></View>);}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

About

A React Native module that provides a native method for replacing selected text in a TextInput with a new text.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages