@@ -8,7 +8,7 @@ An animated floating label `<TextInput>` component for React Native (iOS, Androi
88
99** [ Live demo →] ( https://react-native-floating-labels.js.org ) **
1010
11- ![ Demo] ( https://raw.githubusercontent.com/mayank-patel/react-native-floating-labels/master /demo.gif )
11+ ![ Demo] ( https://raw.githubusercontent.com/mayank-patel/react-native-floating-labels/main /demo.gif )
1212
1313---
1414
@@ -92,6 +92,98 @@ ref.current?.clear();
9292
9393---
9494
95+ ## Testing locally with a React Native app
96+
97+ The quickest way to test the library end-to-end against a real device or simulator before publishing.
98+
99+ ### 1. Create a test app
100+
101+ ** Expo (recommended — no Xcode/Android Studio required for quick tests):**
102+
103+ ``` bash
104+ npx create-expo-app@latest FloatingLabelsTest
105+ cd FloatingLabelsTest
106+ ```
107+
108+ ** Bare React Native:**
109+
110+ ``` bash
111+ npx @react-native-community/cli init FloatingLabelsTest
112+ cd FloatingLabelsTest
113+ ```
114+
115+ ### 2. Pack the library
116+
117+ Run this from the library root. It produces a tarball (e.g. ` react-native-floating-labels-2.0.0.tgz ` ) that mirrors exactly what gets published to npm:
118+
119+ ``` bash
120+ npm run build
121+ npm pack
122+ ```
123+
124+ ### 3. Install the tarball in the test app
125+
126+ ``` bash
127+ npm install /path/to/react-native-floating-labels-2.0.0.tgz
128+ ```
129+
130+ For Expo, no additional linking is required. For bare React Native, run ` npx pod-install ` on iOS.
131+
132+ ### 4. Use it in the app
133+
134+ Replace the contents of ` App.tsx ` (or ` App.js ` ) with:
135+
136+ ``` tsx
137+ import React , {useRef } from ' react' ;
138+ import {Button , SafeAreaView , StyleSheet } from ' react-native' ;
139+ import FloatingLabel , {FloatingLabelHandle } from ' react-native-floating-labels' ;
140+
141+ export default function App() {
142+ const ref = useRef <FloatingLabelHandle >(null );
143+
144+ return (
145+ <SafeAreaView style = { styles .container } >
146+ <FloatingLabel style = { styles .field } >First Name</FloatingLabel >
147+ <FloatingLabel style = { styles .field } secureTextEntry >
148+ Password
149+ </FloatingLabel >
150+ <FloatingLabel ref = { ref } style = { styles .field } >
151+ Ref-controlled field
152+ </FloatingLabel >
153+ <Button title = " Clear via ref" onPress = { () => ref .current ?.clear ()} />
154+ </SafeAreaView >
155+ );
156+ }
157+
158+ const styles = StyleSheet .create ({
159+ container: {flex: 1 , padding: 24 , backgroundColor: ' #fff' },
160+ field: {marginBottom: 16 },
161+ });
162+ ```
163+
164+ ### 5. Start the app
165+
166+ ``` bash
167+ # Expo
168+ npx expo start
169+
170+ # Bare React Native — iOS
171+ npx react-native run-ios
172+
173+ # Bare React Native — Android
174+ npx react-native run-android
175+ ```
176+
177+ ### Testing the beta release from npm
178+
179+ If you want to test the published beta instead of a local tarball:
180+
181+ ``` bash
182+ npm install react-native-floating-labels@beta
183+ ```
184+
185+ ---
186+
95187## Contributing
96188
97189See [ CONTRIBUTING.md] ( ./CONTRIBUTING.md ) for the development workflow, Conventional Commits format, and release process.
0 commit comments