Skip to content

Instantly share code, notes, and snippets.

View singh100ful's full-sized avatar
🎯
Focusing

Ankit Singh singh100ful

🎯
Focusing
View GitHub Profile
@singh100ful
singh100ful / fileform.js
Last active December 28, 2020 08:11
FileForm.js
import React, {Component} from 'react';
import {Formik, Form} from 'formik';
import {Container, Button, Input} from 'reactstrap';
export default class App extends Component {
handleSubmit = (values) => {
let data = new FormData();
data.append("photo1", values.photo1);
return fetch(baseUrl, {
method: "post",
@singh100ful
singh100ful / FieldArrayChildren.js
Created June 12, 2020 00:07
FieldArray Children Type
<Formik initialValues={{ diet: [] }}>
{(formProps) => (
<Form>
<FieldArray name="diet">
{(arrayHelpers) => {
return (
<Form>
{/** whatever you need to do */}
</Form>
);
@singh100ful
singh100ful / FieldArrayComponent.js
Created June 12, 2020 00:04
FieldArray Component Types
export const FormComponent = ({
arrayHelpers
}) => (
<Form>
{/** whatever you need to do */}
</Form>
);
<Formik initialValues={{ diet: [] }}>
{(formProps) => (
@singh100ful
singh100ful / FieldArrayValidation.js
Last active June 11, 2020 23:43
FieldArray Validation
<Formik initialValues={{ diet: [] }}
validationSchema={Yup.object().shape({
diet: Yup.array()
.of(
Yup.object().shape({
food_name: Yup.string().required("Required"),
quantity: Yup.string().required("Required"),
})
)
.required("Required"),
@singh100ful
singh100ful / ArrayHelpers.js
Created June 11, 2020 22:32
FieldArray with ArrayHelpers
<Form style={{ padding: 20 }}>
<FieldArray
name="diet"
render={(arrayHelpers) => (
<div>
<Button
onClick={() => {
arrayHelpers.push({
food_name: "",
quantity: "",
@singh100ful
singh100ful / FieldArray.js
Last active June 11, 2020 20:54
FieldArray Demonstartion
<Formik initialValues={{ diet: [] }}>
{(formProps) => (
<Form>
<FieldArray
name="diet"
render={(arrayHelpers) => (
//FieldArray Form
)}
/>
</Form>
@singh100ful
singh100ful / RNCamera.js
Last active June 5, 2020 21:54
React Native Camera
import React, {Component} from 'react';
import {RNCamera} from 'react-native-camera';
import {View, TouchableOpacity, Text} from 'react-native';
export class App extends Component {
takePicture = async () => {
if (this.camera) {
const options = { width: 500, quality: 0.5 };
const data = await this.camera.takePictureAsync(options);
console.log(data.uri);
@singh100ful
singh100ful / ImagePickerOptions.js
Created June 5, 2020 21:18
Image Picker Options
const options = {
title: 'Select Picture',
storageOptions: {
skipBackup: true,
path: 'images',
},
maxWidth: 500,
maxHeight: 500,
quality: 0.5,
videoQuality: 'medium'
@singh100ful
singh100ful / MainApplication.java
Created May 31, 2020 22:51
Flipper Initialization
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
//initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); <-comment here
}
@singh100ful
singh100ful / ReactNativeFlipper.java
Created May 31, 2020 22:20
Flipper Network Plugin
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
NetworkingModule.setCustomClientBuilder(
new NetworkingModule.CustomClientBuilder() {
@Override
public void apply(OkHttpClient.Builder builder) {
// builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); comment here
}
});
client.addPlugin(networkFlipperPlugin);
client.start();