Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
mfrancois3k / React State Management Recoil
Last active June 8, 2022 06:40
React State Management
// Referencce
https://github.com/manucho007/UltimateCourses/tree/master/react-state-management/course/src
import { atom, useRecoilState } from 'recoil';
// An atom is basically a piece of state
const pageState = atom({
key: 'pageState',
default: 'Home',
});
Array mutations returning a new array
Adding item to an array (list, item)
return [...list, item];
Remove item from index (list, index)
return list
.slice(0,index).concat(list.slice(index+1));
return [...list.slice(0, index),
@mfrancois3k
mfrancois3k / Routes.js
Created June 8, 2022 05:53 — forked from stolinski/Routes.js
React Spring React Router Starter
import React from 'react';
import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom';
const Routes = () => {
return (
<Router>
<ul className="router-nav">
<NavLink to="/">One</NavLink>
<NavLink to="/two">Two</NavLink>
<NavLink to="/three">Three</NavLink>

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

import React from "react";
const Page1 = React.lazy(() => import("./Page1"));
const Page2 = React.lazy(() => import("./Page2"));
const Page3 = React.lazy(() => import("./Page3"));
const routes = [
{
Component: Page1,
path: "page1",
@mfrancois3k
mfrancois3k / Framer Motion Routing App.tsx
Last active August 16, 2022 20:11 — forked from crevulus/App.tsx
Basic Page Transition with Framer
import {
AnimatePresence,
m,
LazyMotion,
domAnimation,
domMax
} from "framer-motion";
import type { CSSProperties } from "react";
import { Link, Route, Routes, useLocation } from "react-router-dom";
import "./styles.css";
import React, { useState, useEffect } from "react";
import { Dimensions, StyleSheet, Text, View } from "react-native";
import * as Location from "expo-location";
import MapView from "react-native-maps";
export const MyMapComponent = () => {
const [location, setLocation] = useState(null);
const [errorMsg, setErrorMsg] = useState(null);
// Request access for location permissions and store them
@mfrancois3k
mfrancois3k / Auth FormikBasicForm.tsx
Last active June 7, 2022 03:35 — forked from phucdph/BasicForm.tsx
[Formik] Validation Schema
const validationSchema = Yup.object().shape<IFormValues>({
name: Yup.string().required("Please enter your name"),
email: Yup.string()
.email("Please enter valid email")
.required("Please enter your email"),
username: Yup.string()
.required("Please enter username")
.min(5, "Your username is too short")
.max(30, "Your username is too long"),
password: Yup.string()
@mfrancois3k
mfrancois3k / Email app.js1
Last active June 8, 2022 17:37 — forked from heitortsergent/app.js1
Email-confirmation Email Tutorial
app.post('/login', function(req,res) {
console.log('user email: ', req.body.email);
res.render('index', {title: 'Sent authentication email'});
});
app.get('/verify_email', function(req,res) {
console.log('verify_email token: ',req.query.token);
res.render('index', {title: 'Authenticating...'});
@mfrancois3k
mfrancois3k / Auth App.js
Created June 5, 2022 21:50 — forked from luishrd/App.js
JWT Server, all other files remain the same
// /src/App.js
import React, { Component } from 'react';
import { Route, withRouter } from 'react-router-dom';
import logo from './logo.svg';
import './App.css';
import Signin from './auth/Signin';
import Users from './users/Users';