Skip to content

Instantly share code, notes, and snippets.

Jared Palmer jaredpalmer

Block or report user

Report or block jaredpalmer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jaredpalmer / EmailInput.jsx
Created Nov 29, 2017
Formik async email signup input
View EmailInput.jsx
import React from 'react';
import debounce from 'utils/debounce';
class EmailInput extends React.Component {
checkEmail = value => {
// only check if the field passes Yup email validation first
if (
'invalid' /* or whatever your error message is*/
jaredpalmer / razzle.config.js
Created Jan 25, 2018
Razzle TS real-world setup
View razzle.config.js
'use strict';
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const scssPlugin = new ExtractTextPlugin(
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
View Formik-Autosave.jsx
import React from 'react';
import PropTypes from 'prop-types'
import debounce from 'lodash.debounce' // or whatevs
import isEqual from 'lodash.isEqual'
class AutoSave extends React.Component {
static contextTypes = {
formik: PropTypes.object
View SketchSystems.spec
setFieldValue -> VALIDATING
setValues -> VALIDATING
setTouched -> VALIDATING
setFieldTouched -> VALIDATING
handleChange -> VALIDATING
handleBlur -> VALIDATING
handleSubmit -> Submit Attempted
submitForm -> Submit Attempted
jaredpalmer / App.js
Created May 30, 2017
Next.js-like SSR without Next.js.
View App.js
import React from 'react';
import Route from 'react-router-dom/Route';
import Link from 'react-router-dom/Link';
import Switch from 'react-router-dom/Switch';
const App = ({ routes, initialData }) => {
return routes
? <div>
{, index) => {
View banned.txt
2 girls 1 cup
View withSSR.js
import React from 'react';
import axios from 'axios';
// This is a Higher Order Component that abstracts duplicated data fetching
// on the server and client.
export default function SSR(Page) {
class SSR extends React.Component {
static getInitialData(ctx) {
// Need to call the wrapped components getInitialData if it exists
return Page.getInitialData
jaredpalmer / ReducerComponent.js
Last active Jul 27, 2019
View ReducerComponent.js
import React from 'react';
class ReducerComponent extends React.Component {
constructor(props) {
reducer = (state, action) => state;
dispatch = action => this.setState(state => this.reducer(state, action));
View reducerComponent2.js
import React from 'react';
class ReducerComponent extends React.Component {
constructor(props) {
View Custom-Input-render-props.jsx
import React from 'react'
import { Formik, Field, Form } from 'formik'
const MyInput = ({ field, form, }) =>
<input {...field} {} />
&& form.touched[]
&& <div>{form.errors[]}</div>}
You can’t perform that action at this time.