Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
mfrancois3k / redux-ajax.js
Created February 20, 2022 02:40 — forked from aamnah/redux-ajax.js
[work-in-progress] Redux + AJAX basics
// Basic AJAX Example
import React, { Component } from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware, combineReducers } from 'redux'
import { Provider, connect } from 'react-redux'
import axios from 'axios'
import createLogger from 'redux-logger'
import thunkMiddleware from 'redux-thunk'
const logger = createLogger()
@mfrancois3k
mfrancois3k / getbooks.js
Created February 20, 2022 02:41 — forked from smokeyfro/getbooks.js
Saved in ./config/functions/getbooks.js
const axios = require('axios');
module.exports = async () => {
// Get all books at once using map (or object)
const allReviews = new Map([
['isbn:9781491997246', { isbn: "9781491997246", short_title: "Vue.js: Up and Running", status: 0, review: "", category: "work", tags: ["javascript","vue","coding"] }],
['isbn:9781617294624', { isbn: "9781617294624", short_title: "", status: 0, review: "", category: "work", tags: ["javascript","vue","coding"] }],
['isbn:9781484238042', { isbn: "9781484238042", short_title: "", status: 0, review: "", category: "work", tags: ["javascript","vue","coding"] }],
['isbn:9781786469946', { isbn: "9781786469946", short_title: "Learning Vue.js 2", status: 0, review: "", category: "work", tags: ["javascript","vue","coding"] }],
@mfrancois3k
mfrancois3k / mern-e2e-deploy.md
Last active August 1, 2022 05:36 — forked from LevPewPew/mern-e2e-deploy.md
fully detailed process of getting a mern app deployment

full proper step by step deploy MERN

using "cool-fruit-app" and a "banana" model for the example

initial setup

1. create a top level folder

mkdir cool-fruit-app cd cool-fruit-app

@mfrancois3k
mfrancois3k / Mailer.js
Created February 20, 2022 05:04 — forked from GiriVakkalanka/Mailer.js
SendGrid setup
const sendgrid = require('sendgrid');
const helper = sendgrid.mail; //don't want to use es6 destructuring b.c we want to call it helper. not mail.
const keys = require('../config/keys');
class Mailer extends helper.Mail {
//constructor doesnt need to receive a survey model obj.
//It just has to be an object that has a subject and recipients.
//the second parameter is the html string, that we'll call content
//this design lets us use this Mailer for sending more than just surveys
//this mailer obj is defined here created in the surveyRoutes to send the emails.
@mfrancois3k
mfrancois3k / .env
Created February 20, 2022 05:06 — forked from kyttike/.env
.env files setup
REACT_APP_API_URL=123123123
REACT_APP_APP_URL=123123123
REACT_APP_PAGE_URL=123123123
REACT_APP_FACEBOOK_PIXEL=123123123
REACT_APP_GOOGLE_TAG_MANAGER=123123123
REACT_APP_GEOLOCALIZATION=123123123
@mfrancois3k
mfrancois3k / App.jsx
Created February 20, 2022 07:51 — forked from farhad0085/App.jsx
React Redux setup boilerplate
// src/App.jsx
import React, { Component } from 'react';
import { connect } from 'react-redux'
import Count from './components/Count';
import Controller from './components/Controller'
import { login, logout } from "./store/actions/authActions";
@mfrancois3k
mfrancois3k / reduxSetup.txt
Created February 20, 2022 07:52 — forked from markodayan/reduxSetup.txt
Redux setup and explanations (General and React setup)
a Basic redux setup in a React application covering fundamental steps
#1 Create store (using 'redux'), we will pass the root reducer in here later (root reducer contains all other reducers)
#2 Wrap App root element in Provider (from 'react-redux')
#3 Create a root reducer file with reducer function with args of state & action and returning state. define init state
at top of file and feed as state arg
- We can create multiple reducers for different parts of our app to handle their own set of actions and then combine these reducers into one Root Reducer and pass it into the store.
- We can make reducers in their own files, then in the rootReducer file -> use the combineReducers method from 'redux' to combine all the reducers into the rootReducer
@mfrancois3k
mfrancois3k / actions.js
Created February 20, 2022 07:55 — forked from wtshek/actions.js
setup #redux-thunk
import jsonPlaceholder from "../api/jsonPlaceholder";
export const fetchPosts = () => async dispatch => {
const response = await jsonPlaceholder.get("/posts");
dispatch({type:"FETCH_POSTS", payload: response })
}
//with getState
export const fetchPosts = () => {
@mfrancois3k
mfrancois3k / AnimatedSwitch.jsx
Created February 20, 2022 07:56 — forked from Jeyloh/AnimatedSwitch.jsx
React framer-motion route animations
import React from "react";
import { Switch } from "react-router-dom";
import { useSelector } from "react-redux";
import { AnimatePresence, motion } from "framer-motion";
import { getPlatform, isMobilePlatform } from "../util/browser.helper";
import styled from "styled-components";
import { ROUTES } from "constants/routes.const";
// This can be tweaked for speed and opacity on enter-exit animations.
const variants = {