To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.
- Homebrew
- Mountain Lion
| import firebase from "firebase/app"; | |
| import "firebase/auth"; | |
| import { gql, GraphQLClient } from "graphql-request"; | |
| import { SWRConfig } from "swr"; | |
| import create from "zustand"; | |
| import { computed } from "zustand-middleware-computed-state"; | |
| const firebaseConfig = { | |
| // | |
| }; |
| import React from 'react'; | |
| import { useQuery, useQueryClient, UseQueryOptions } from 'react-query'; | |
| import realTimeApi from './real-time-api'; | |
| function useRealTimeQuery<Data>( | |
| firebasePathKey: string, | |
| useQueryOptions: UseQueryOptions<Data> = {} | |
| ) { | |
| const queryClient = useQueryClient(); |
| //MIT License | |
| //Copyright (c) 2021 Felix Westin | |
| //Source: https://github.com/Fewes/MinimalAtmosphere | |
| //Ported to GLSL by Marcin Ignac | |
| #ifndef ATMOSPHERE_INCLUDED | |
| #define ATMOSPHERE_INCLUDED | |
| // ------------------------------------- |
| import React from "react"; | |
| import { Link } from "react-router-dom"; | |
| export function createResource(getPromise) { | |
| let cache = {}; | |
| let inflight = {}; | |
| let errors = {}; | |
| function load(key) { | |
| inflight[key] = getPromise(key) |
| export const open: Action = async ({ state, actions, effects }) => { | |
| state.currentPage = Page.ADMIN | |
| const messageUpdates = await effects.api.getAdminMessageUpdates() | |
| state.admin.messageUpdates = messageUpdates | |
| state.admin.users = await effects.api.getUsers( | |
| messageUpdates.map((update) => update.userUid) | |
| ) | |
| if (state.admin.messageUpdates.length) { | |
| state.admin.isLoadingFeed = true |
| import React, { useEffect } from "react" | |
| import useFetch from "./useFetch" | |
| export default function ProcessingPurchase({ | |
| send, | |
| context: { workshopData, ticketsToPurchase, stripeToken } | |
| }) { | |
| let [charge, error] = useFetch("/purchaseWorkshop", { | |
| workshopId: workshopData.id, | |
| ticketsToPurchase, |
To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.
| function prefetch(getKey, getValue, getInitialValue, propName) { | |
| const inFlight = new Set(); | |
| const cache = new Map(); | |
| return ChildComponent => { | |
| return class extends React.Component { | |
| state = {value: getInitialValue(this.props)}; | |
| componentWillReceiveProps(nextProps) { | |
| const key = getKey(nextProps); | |
| if (cache.has(key)) { | |
| // Use cached value |
| import { Component } from 'react' | |
| import { createStore, combineReducers } from 'redux' | |
| import parseLinkHeader from 'parse-link-header' | |
| const START = 'start' | |
| const SUCCEED = 'succeed' | |
| const ERROR = 'error' | |
| const inflight = (state={}, action) => ( | |
| ((state) => ( |
| // See https://blog.isquaredsoftware.com/presentations/react-redux-ts-intro-2020-12/#/36 for slides | |
| // My basic render function structure: | |
| function RenderLogicExample({ | |
| someBoolean, // 1) Destructure values from `props` object | |
| someList, | |
| }) { | |
| // 2) Declare state values | |
| const [a, setA] = useState(0); | |
| const [b, setB] = useState(0); |