Skip to content

Instantly share code, notes, and snippets.

View GenesisSam's full-sized avatar
👋

Samuel Lee GenesisSam

👋
View GitHub Profile
import * as React from "react";
import axios, { CancelTokenSource } from "axios";
export default function useCancelToken(
identity?: any,
): {
current: CancelTokenSource;
cancelAndRenewal(): void;
} {
const cancelTokenSource: React.MutableRefObject<
import * as React from "react";
import { useDebounce } from "react-use";
import { useActions, useStoreState } from "app/store";
import { searchedUsersSelector, searchedUsersWithoutCurrentUserSelector } from "app/selectors/search";
import useCancelToken from "common/hooks/useCancelToken";
import {
ActionCreators,
getSearchUsers as getSearchUsersAction,
} from "app/actions/user";
const CustomTextRenderInput: React.FC<IProps> = ({
readonly,
value = "",
onChange,
}) => {
const [currentOriginalContent, setOriginalContent] = React.useState(value);
const [currentRenderedContent, setRenderedContent] = React.useState(
mentionRender(value, CommonRenderer),
);
const handleChange = React.useCallback((e: ContentEditableEvent) => {
@GenesisSam
GenesisSam / App.tsx
Created February 22, 2019 09:09
Not using Hook
import React, { Component } from "react";
import { Router, Switch, Route } from "react-router-dom";
import styled from "styled-components";
import { createBrowserHistory } from "history";
import MenuBar from "./components/menu";
import Home from "./components/home";
import SignIn from "./components/signIn";
import { getAuthToken } from "./helpers/authHelper";
@GenesisSam
GenesisSam / SignIn.tsx
Last active February 22, 2019 09:28
Using Hook
import * as React from "react";
import { useAuthState } from "../../helpers/authHelper";
import { Redirect } from "react-router";
const SignIn = () => {
const [username, setUsername] = React.useState("");
const [password, setPassword] = React.useState("");
const [isSignedIn, setAuth] = useAuthState();
if (isSignedIn) {
return <Redirect to="/home" />;