Skip to content

Commit 608997c

Browse files
committed
Changed import method with placeholder autodectection, Update README, version 1.0.1
1 parent dca13ec commit 608997c

File tree

7 files changed

+490
-485
lines changed

7 files changed

+490
-485
lines changed

Example/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
"react": "16.8.3",
1313
"react-dom": "^16.8.6",
1414
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
15-
"react-native-input-validator": "^1.0.0",
16-
"react-native-web": "^0.11.4",
17-
"validator": "^11.0.0"
15+
"react-native-input-validator": "^1.0.1",
16+
"react-native-web": "^0.11.4"
1817
},
1918
"devDependencies": {
2019
"babel-preset-expo": "^5.1.1"

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@ yarn add react-native-input-validator
3535

3636
### Require
3737

38-
This library have 2 componets `InputValidator` and `InputText`.
39-
The first have floating labels (placeholder) and the second one not.
4038

4139
```javascript
42-
include {InputValidator, InputText} from 'react-native-input-validator';
40+
include TextInput from 'react-native-input-validator';
4341
```
4442

45-
### Placeholder floating label
43+
### Examples
44+
45+
46+
#### Placeholder floating label
4647
```javascript
4748
// Require
48-
include {InputValidator} from 'react-native-input-validator';
49+
include TextInput from 'react-native-input-validator';
4950

5051
// Example
5152
<InputValidator
@@ -65,10 +66,10 @@ this.input.isValidated(); // Faster
6566
this.input.isValid();
6667
```
6768

68-
### Only text input
69+
#### Only text input
6970
```javascript
7071
// Require
71-
include {InputText} from 'react-native-input-validator';
72+
include TextInput from 'react-native-input-validator';
7273

7374
// Example
7475
<InputText
@@ -77,11 +78,7 @@ include {InputText} from 'react-native-input-validator';
7778
}}
7879
value={this.state.value}
7980
style={styles.input}
80-
onChangeText={(text) => {this.setState({value: text})}}>
81-
82-
<Text>Default</Text>
83-
84-
</InputText>
81+
onChangeText={(text) => {this.setState({value: text})}} />
8582

8683
// Check Validation
8784
this.input.isValidated(); // Faster

index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
import React, {Component, Children} from 'react';
2+
import InputValidator from "./src/InputValidator";
3+
import InputValidatorPlaceholder from "./src/InputValidatorPlaceholder";
4+
15
/**
26
* react-native-input-validator
37
* @author Marco Cesarato <[email protected]>
48
*/
5-
6-
export {default as InputValidator} from "./src/InputValidator";
7-
export {default as InputText} from "./src/InputText";
9+
export default class TextInput extends Component {
10+
render() {
11+
if (Children.count(this.props.children)) {
12+
return (<InputValidatorPlaceholder {...this.props}/>);
13+
}
14+
return (<InputValidator {...this.props}/>);
15+
}
16+
}

screenshots/example.png

3.08 KB
Loading

0 commit comments

Comments
 (0)