Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
mfrancois3k / useForm.ts
Created February 21, 2022 02:37 — forked from AZagatti/useForm.ts
useForm
import { useCallback, useState, ChangeEvent } from "react";
function useForm<T>(initialData: T) {
const [values, setValues] = useState<T>(initialData);
const setValue = useCallback((key: string | null, value: string) => {
if (!key) return;
setValues((state) => ({ ...state, [key]: value }));
}, []);
import { gql, useMutation, useQuery } from "@apollo/client";
import useSWR from "swr";
import Layout from "../../components/Layout";
import React, { useState } from "react";
import {
useTable,
usePagination,
useFilters,
useGlobalFilter,
useAsyncDebounce,
// <script src="https://cdnjs.cloudflare.com/ajax/libs/expect/1.20.2/expect.min.js"></script>
// redux api
const combineReducers = reducers =>
(state = {}, action) =>
Object.keys (reducers).
reduce ((accumulator, key) => Object.assign ({}, accumulator, {[key]: reducers [key] (state [key], action)}), {})
Video Tutorial:
https://egghead.io/series/getting-started-with-redux
Lesson 05:
Redux: Writing a Counter Reducer with Tests
http://jsbin.com/piqapi/edit?js,console
Lesson 06:
Redux: Store Methods: getState(), dispatch(), and subscribe()
http://jsbin.com/jadunek/edit?js,console
@mfrancois3k
mfrancois3k / Create Component's reducer
Created February 22, 2022 06:30 — forked from vanya2h/Create Component's reducer
React Redux JSDoc snippets for VSCode
{
"Create reducer file": {
"prefix": "reducer",
"body": [
"/**",
" * $1 component's reducer",
" * @name $1Reducer",
" * @memberof app.reducers",
" * @typedef $1Reducer",
" * @default {}",
@mfrancois3k
mfrancois3k / javascript.json
Created February 22, 2022 06:49 — forked from alicanerdogan/javascript.json
React/Redux Snippets for VSCode
{
"Set component state": {
"prefix": "%setstate",
"description": "Call set state function",
"body": [
"this.setState(state => Object.assign({}, state, {$1}));"
]
},
"Modify state": {
"prefix": "%modifystate",
@mfrancois3k
mfrancois3k / Sum
Created February 22, 2022 20:31 — forked from MeliAlbu/Sum
class Sum extends Component {
constructor(props) {
super(props);
this.state = {
firstValue: "",
secondValue: "",
sumVar: "",
};
}
@mfrancois3k
mfrancois3k / remote-debugging.md
Created February 22, 2022 20:42 — forked from BPagoaga/remote-debugging.md
Remote debugging

How to remote debug

Debug a project accessed from a remote device.This device should be connected to your local machine via usb.

Step 1: serve your project on host 0.0.0.0

To be able to access your local project from a remote device, you might serve it on the 0.0.0.0 host: npm start -- --host 0.0.0.0

Step 2: activate the usb debugging on your remote device