Last active
June 23, 2018 01:05
-
-
Save devendrabhandari/a39ca29320da9aff1b540c38b8428e64 to your computer and use it in GitHub Desktop.
React Native - Basic Util Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#React-Native: How to use common functions | |
1. Create a file 'validate.js'. | |
2. Add few function like this | |
export function isEmpty(str) { | |
return (!str || 0 === str.length); | |
} | |
export function validateEmail(email) { | |
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; | |
if (filter.test(email)) return true; | |
return false; | |
} | |
3. Then you can use it inside the component. | |
import { isEmpty } from './utils/validate'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment