Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devendrabhandari/a39ca29320da9aff1b540c38b8428e64 to your computer and use it in GitHub Desktop.
Save devendrabhandari/a39ca29320da9aff1b540c38b8428e64 to your computer and use it in GitHub Desktop.
React Native - Basic Util Functions
#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