Skip to content

Commit e2d356c

Browse files
author
Will
committed
docs: updated lib documentation
1 parent 1d3cac0 commit e2d356c

5 files changed

Lines changed: 47 additions & 28 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ node_modules
66
npm-debug.log
77

88
# Runtime data
9-
tmp
9+
tmp
10+
11+
.DS_Store

README.md

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<br>
22

33
<div align = "center">
4-
<img src="lib/assets/images/preview.png" alt="React Native Country Picker and Select Lib preview">
4+
<img src="https://astroonauta.github.io/react-native-country-select/lib/assets/images/preview.png" alt="React Native Country Picker and Select Lib preview">
55
</div>
66

77
<br>
@@ -123,8 +123,8 @@ npx react-native-asset
123123
- Class Component
124124
125125
```jsx
126-
import React, {Component} from 'react';
127-
import {Text, TouchableOpacity, View} from 'react-native';
126+
import React, { Component } from 'react';
127+
import { Text, TouchableOpacity, View } from 'react-native';
128128
import CountrySelect from 'react-native-country-select';
129129

130130
export default class App extends Component {
@@ -138,14 +138,16 @@ export default class App extends Component {
138138
};
139139
}
140140

141-
handleCountrySelect = country => {
142-
this.setState({country});
141+
handleCountrySelect = (country) => {
142+
this.setState({ country });
143143
};
144144

145145
render() {
146146
return (
147-
<View style={{flex: 1}}>
148-
<TouchableOpacity onPress={() => this.setState({showPicker: true})}>
147+
<View style={{ flex: 1 }}>
148+
<TouchableOpacity
149+
onPress={() => this.setState({ showPicker: true })}
150+
>
149151
<Text>Select Country</Text>
150152
</TouchableOpacity>
151153
<Text>
@@ -155,7 +157,7 @@ export default class App extends Component {
155157

156158
<CountrySelect
157159
visible={this.state.showPicker}
158-
onClose={() => this.setState({showPicker: false})}
160+
onClose={() => this.setState({ showPicker: false })}
159161
onSelect={this.handleCountrySelect}
160162
/>
161163
</View>
@@ -169,29 +171,31 @@ export default class App extends Component {
169171
- Function Component
170172
171173
```jsx
172-
import React, {useState} from 'react';
173-
import {Text, TouchableOpacity, View} from 'react-native';
174+
import React, { useState } from 'react';
175+
import { Text, TouchableOpacity, View } from 'react-native';
174176

175177
import CountrySelect from 'react-native-country-select';
176178

177179
export default function App() {
178180
const [showPicker, setShowPicker] = useState(false);
179181
const [selectedCountry, setSelectedCountry] = useState(null);
180182

181-
const handleCountrySelect = country => {
183+
const handleCountrySelect = (country) => {
182184
setSelectedCountry(country);
183185
};
184186

185187
return (
186188
<View
187189
style={{
188190
flex: 1,
189-
}}>
191+
}}
192+
>
190193
<TouchableOpacity onPress={() => setShowPicker(true)}>
191194
<Text>Select Country</Text>
192195
</TouchableOpacity>
193196
<Text>
194-
Country: {`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
197+
Country:{' '}
198+
{`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
195199
</Text>
196200

197201
<CountrySelect
@@ -209,14 +213,15 @@ export default function App() {
209213
- Typescript
210214
211215
```tsx
212-
import React, {useState} from 'react';
213-
import {Text, TouchableOpacity, View} from 'react-native';
216+
import React, { useState } from 'react';
217+
import { Text, TouchableOpacity, View } from 'react-native';
214218

215-
import CountrySelect, {ICountry} from 'react-native-country-select';
219+
import CountrySelect, { ICountry } from 'react-native-country-select';
216220

217221
export default function App() {
218222
const [showPicker, setShowPicker] = useState<boolean>(false);
219-
const [selectedCountry, setSelectedCountry] = useState<ICountry | null>(null);
223+
const [selectedCountry, setSelectedCountry] =
224+
useState<ICountry | null>(null);
220225

221226
const handleCountrySelect = (country: ICountry) => {
222227
setSelectedCountry(country);
@@ -226,12 +231,14 @@ export default function App() {
226231
<View
227232
style={{
228233
flex: 1,
229-
}}>
234+
}}
235+
>
230236
<TouchableOpacity onPress={() => setShowPicker(true)}>
231237
<Text>Select Country</Text>
232238
</TouchableOpacity>
233239
<Text>
234-
Country: {`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
240+
Country:{' '}
241+
{`${selectedCountry?.name?.common} (${selectedCountry?.cca2})`}
235242
</Text>
236243

237244
<CountrySelect
@@ -249,14 +256,16 @@ export default function App() {
249256
- Multi Select Country
250257
251258
```tsx
252-
import React, {useState} from 'react';
253-
import {Text, TouchableOpacity, View} from 'react-native';
259+
import React, { useState } from 'react';
260+
import { Text, TouchableOpacity, View } from 'react-native';
254261

255-
import CountrySelect, {ICountry} from 'react-native-country-select';
262+
import CountrySelect, { ICountry } from 'react-native-country-select';
256263

257264
export default function App() {
258265
const [showPicker, setShowPicker] = useState<boolean>(false);
259-
const [selectedCountries, setSelectedCountries] = useState<ICountry[]>([]);
266+
const [selectedCountries, setSelectedCountries] = useState<
267+
ICountry[]
268+
>([]);
260269

261270
const handleCountrySelect = (countries: ICountry[]) => {
262271
setSelectedCountries(countries);
@@ -266,7 +275,8 @@ export default function App() {
266275
<View
267276
style={{
268277
flex: 1,
269-
}}>
278+
}}
279+
>
270280
<TouchableOpacity onPress={() => setShowPicker(true)}>
271281
<Text>Select Countries</Text>
272282
</TouchableOpacity>
@@ -355,6 +365,7 @@ export default function App() {
355365
| allCountriesTitle | string | No | 'All Countries' | All Countries section title |
356366
| showsVerticalScrollIndicator | boolean | No | false | Displays a horizontal scroll indicator |
357367
| countryNotFoundMessage | string | No | "No countries found" | Country not found in search |
368+
| allowFontScaling | boolean | No | true | Whether to allow font scaling for text elements |
358369
359370
<br>
360371
@@ -405,13 +416,19 @@ The `language` prop supports the following values:
405416
When utilizing this package, you may need to target the CountrySelect component in your automated tests. To facilitate this, we provide a testID props for the CountrySelect component. The testID can be integrated with popular testing libraries such as @testing-library/react-native or Maestro. This enables you to efficiently locate and interact with CountrySelect elements within your tests, ensuring a robust and reliable testing experience.
406417
407418
```js
408-
const countrySelectModalContainer = getByTestId('countrySelectContainer');
419+
const countrySelectModalContainer = getByTestId(
420+
'countrySelectContainer'
421+
);
409422
const countrySelectModalContent = getByTestId('countrySelectContent');
410423
const countrySelectBackdrop = getByTestId('countrySelectBackdrop');
411424
const countrySelectList = getByTestId('countrySelectList');
412-
const countrySelectSearchInput = getByTestId('countrySelectSearchInput');
425+
const countrySelectSearchInput = getByTestId(
426+
'countrySelectSearchInput'
427+
);
413428
const countrySelectItem = getByTestId('countrySelectItem');
414-
const countrySelectCloseButton = getByTestId('countrySelectCloseButton');
429+
const countrySelectCloseButton = getByTestId(
430+
'countrySelectCloseButton'
431+
);
415432
```
416433
417434
<br>

lib/.DS_Store

8 KB
Binary file not shown.

lib/assets/.DS_Store

10 KB
Binary file not shown.

0 commit comments

Comments
 (0)