Skip to content

Commit 9fbf591

Browse files
committed
change some variable name + update README
1 parent c6d4ecd commit 9fbf591

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A react-native confirmation code input for both IOS and Android
55
- A user-friendly component for inputting confirmation code
66
- Extended from [<TextInput/>](https://facebook.github.io/react-native/docs/textinput.html) component, so you can use its props
77
- Built-in type of code input: underline, box, circle
8-
- Set position: center, left, right, fill width
8+
- Set position: center, left, right, full width
99
- Set size and active color, inactive color
1010
- Easy to customize style, use base style from TextInput component
1111
- Check code on finish or return code for async checking
@@ -74,16 +74,14 @@ render() {
7474
}
7575
```
7676

77-
### Customization
78-
79-
### Properties
77+
### props
8078
This component uses the same props as [<TextInput/>](https://facebook.github.io/react-native/docs/textinput.html). Below are additional props for this component:
8179

8280
Prop | Type | Default | Description
8381
---------- | ------- | ---------- | -----------------------
8482
`codeLength` | number | 5 | length of confirmation code -> number of cells
8583
`compareWithCode` | string | | code to compare. if null, onFulfill callback return inputted code to check later
86-
`inputPosition` | string | `center` | position of code input in its container
84+
`inputPosition` | string | `center` | position of code input in its container: `left`, `right`, `center`, `full-width`
8785
`size` | number | 40 | size of input cells
8886
`space` | number | 8 | space between 2 cells
8987
`className` | string | `border-box` | Some built-in classname: `border-box`, `border-circle`, `border-b`, `border-b-t`, `border-l-r`
@@ -96,9 +94,24 @@ Prop | Type | Default | Description
9694
`containerStyle` | style object | | custom style for code input container
9795
`onFulfill` | function | | callback function called when fulfilling code. If `compareWithCode` is null -> return `(code)` in callback, else return `(isValid, code)`. **Required**
9896

97+
## functions
98+
clear input:
99+
```javascript
100+
this.refs.refName.clear();
101+
...
102+
<CodeInput
103+
...
104+
ref="refName"
105+
/>
106+
```
99107
## Example
100108
See [EXAMPLE](example)
101-
109+
```sh
110+
git clone https://github.com/ttdung11t2/react-native-confirmation-code-input.git
111+
cd react-native-confirmation-code-input/example
112+
npm install
113+
react-native run-ios / react-native run-android
114+
```
102115
## License
103116

104117
react-native-confirmation-code-input is released under the MIT license. See [LICENSE](LICENSE) for details.

components/ConfirmationCodeInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default class ConfirmationCodeInput extends Component {
5252
console.error("Invalid props: compareWith length is not equal to codeLength");
5353
}
5454

55-
if (_.indexOf(['center', 'left', 'right', 'full'], inputPosition) === -1) {
55+
if (_.indexOf(['center', 'left', 'right', 'full-width'], inputPosition) === -1) {
5656
console.error('Invalid input position. Must be in: center, left, right, full');
5757
}
5858
}

example/src/components/ConfirmationCodeInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default class ConfirmationCodeInput extends Component {
5252
console.error("Invalid props: compareWith length is not equal to codeLength");
5353
}
5454

55-
if (_.indexOf(['center', 'left', 'right', 'full'], inputPosition) === -1) {
55+
if (_.indexOf(['center', 'left', 'right', 'full-width'], inputPosition) === -1) {
5656
console.error('Invalid input position. Must be in: center, left, right, full');
5757
}
5858
}

0 commit comments

Comments
 (0)