Skip to content

Instantly share code, notes, and snippets.

View jaredpalmer's full-sized avatar

Jared Palmer jaredpalmer

View GitHub Profile
import React from 'react';
class ReducerComponent extends React.Component {
constructor(props) {
super(props);
}
@jaredpalmer
jaredpalmer / ReducerComponent.js
Last active July 27, 2019 15:59
React.ReducerComponent
import React from 'react';
class ReducerComponent extends React.Component {
constructor(props) {
super(props);
}
reducer = (state, action) => state;
dispatch = action => this.setState(state => this.reducer(state, action));
@jaredpalmer
jaredpalmer / React Color Picker.yaml
Created August 30, 2017 14:54
Shared with Script Lab
name: React Color Picker
description: ''
author: jaredpalmer
host: EXCEL
api_set: {}
script:
content: |+
async function colorCell(color = "yellow") {
await Excel.run(async (context) => {
const range = context.workbook.getSelectedRange();
@jaredpalmer
jaredpalmer / setup.js
Created August 29, 2017 17:31
Modify Create React App TypeScript
'use strict';
const fs = require('fs');
const path = require('path');
const paths = {
webpackDev: path.resolve(
`./node_modules/react-scripts-ts/config/webpack.config.dev.js`
),
webpackProd: path.resolve(
@jaredpalmer
jaredpalmer / patch.js
Created August 26, 2017 21:06
Change the port in CRA's WebpackHotDevClient.
const fs = require('fs');
// Monkey-patch react-dev-utils to get the error overlay with SSR
const pathToDevClient = 'node_modules/react-dev-utils/webpackHotDevClient.js';
// The react-scripts default
const reactScriptsPort = 3000;
// Read the dev client out of node_modules
const HotDevClient = fs.readFileSync(pathToDevClient, 'utf8');
@jaredpalmer
jaredpalmer / server.js
Last active August 26, 2017 20:12
CRA SSR Hacking
// src/server.js
import App from './App';
import React from 'react';
import express from 'express';
import fs from 'fs';
import path from 'path';
import { renderToString } from 'react-dom/server';
const server = express();
@jaredpalmer
jaredpalmer / .babelrc
Created August 26, 2017 19:40
babelrc
{
"presets": [
"react-app"
]
}
const path = require('path');
module.exports = {
webpack: (config, options, webpack) => {
// change Backpack's default entry point to 'src/server.js'
config.entry.main = path.join(__dirname, 'src/server.js');
// Tell Backpack how to handle .css files (load into memory and noop)
config.module.rules.push({
@jaredpalmer
jaredpalmer / SidebarGroup.tsx
Last active August 14, 2017 02:45
typescript jsxstyle example
import * as React from 'react';
import { Block, Row } from 'jsxstyle';
import { SidebarNavLink } from './SidebarNavLink';
import { COLORS } from '../theme';
export interface SidebarGroupItemProps {
name: string;
link: string;
@jaredpalmer
jaredpalmer / server.js
Created August 10, 2017 13:30
JSXStyle x React Router 4 x SSR
import { injectAddRule, resetCache } from 'jsxstyle/lib/styleCache';
import App from './App';
import React from 'react';
import { StaticRouter } from 'react-router-dom';
import express from 'express';
import path from 'path';
import { renderToString } from 'react-dom/server';
const assets = require(process.env.RAZZLE_ASSETS_MANIFEST);