Posts

React Native formik + yup

    Run the following command with your project directory      npm i  formik and  npm i  yup Code for Form Validation in React Native Open App.js in any code editor and replace the code with the following code App.js import * as yup from 'yup' import { Formik } from 'formik' import React, { Component, Fragment } from 'react'; import { TextInput, Text, Button, Alert } from 'react-native'; export default class App extends Component { render() { return ( <Formik initialValues={{ email: '', password: '' }} onSubmit={values => Alert.alert(JSON.stringify(values))} validationSchema={yup.object().shape({ email: yup .string() .email() .required(), password: yup .string() .min(6) .required(), })} > {({ values, handleChange, errors, setFieldTouched, touched, isValid, handleSubmit }) => (...

React Native Image Picker

Run the following command with your project directory npm install react- native -image-picker --save We are using a Native API Camera and also going to choose the image from the gallery so we need to add some permission to the  AndroidManifest.xml  file. < uses-permission android:name = "android.permission.CAMERA" /> < uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" /> Code for Image Picker in React Native open App.js in any code editor and replace the code with the following code App.js import React,{Component} from 'react'; import {      StyleSheet,      View,      Button,      Image,      Text } from 'react-native'; import ImagePicker from 'react-native-image-picker'; export default class App extends Component {      constructor(props) {     super(props);          this.state = {         ...