Skip to content

Instantly share code, notes, and snippets.

View mrasadatik's full-sized avatar
🇧🇩

Asaduzzaman Atik mrasadatik

🇧🇩
View GitHub Profile
@mrasadatik
mrasadatik / contextapi.md
Last active May 10, 2022 12:58
Detailed example and implementation of React ContextAPI

//!!!!! JavaScript Solution - For TypeScript visit my profile

/* Implement React ContextAPI using the complex way
and use it to the calmy way.
Optional COOKIE feature added (npm i universal-cookie)*/

//** First thing first create a provider component
//** 📄 StateProvider.js (.jsx)
import * as React from "react";
/*import Cookies from "universal-cookie";
@mrasadatik
mrasadatik / contextapits.md
Last active May 10, 2022 12:57
Detailed example and implementation of React ContextAPI in TypeScript way

//!!!!! TypeScript Solution - For JavaScript visit my profile

/* Implement React ContextAPI in TypeScript using the complex way
and use it to the calmy way.
Optional COOKIE feature added (npm i universal-cookie)*/

//** First thing first create a provider component
//** 📄 StateProvider.ts (.tsx)
import * as React from "react";
/*import Cookies from "universal-cookie";
@mrasadatik
mrasadatik / use-validation-schema.ts
Last active March 10, 2024 05:35 — forked from nfantone/use-validation-schema.js
Use `yup` with `react-final-form` (TypeScript)
import { setIn } from "final-form";
import { useMemo } from "react";
import { ObjectSchema, ValidationError, InferType } from "yup";
/**
* Sets the `innerError.message` in an `errors` object at the key
* defined by `innerError.path`.
* @param {Record<string, string>} errors The object to set the error in.
* @param {ValidationError} innerError A `yup` field error.
* @returns {Record<string, string>} The result of setting the new error message onto `errors`.