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
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 (
!this.props.form.errors[this.props.name].includes(
'invalid' /* or whatever your error message is*/
)
@jaredpalmer
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(
'static/css/[name].[contenthash:8].css'
);
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
Formik
IDLE*
setFieldValue -> VALIDATING
setValues -> VALIDATING
setTouched -> VALIDATING
setFieldTouched -> VALIDATING
handleChange -> VALIDATING
handleBlur -> VALIDATING
handleSubmit -> Submit Attempted
submitForm -> Submit Attempted
@jaredpalmer
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>
<Switch>
{routes.map((route, index) => {
View banned.txt
.htaccess
.htpasswd
.well-known
(null)
+++ATH0
2 girls 1 cup
2g1c
400
401
403
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
jaredpalmer / ReducerComponent.js
Last active Jul 27, 2019
React.ReducerComponent
View ReducerComponent.js
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));
View reducerComponent2.js
import React from 'react';
class ReducerComponent extends React.Component {
constructor(props) {
super(props);
}
View Custom-Input-render-props.jsx
import React from 'react'
import { Formik, Field, Form } from 'formik'
const MyInput = ({ field, form, ...rest }) =>
<div>
<input {...field} {...rest} />
{form.errors[field.name]
&& form.touched[field.name]
&& <div>{form.errors[field.name]}</div>}
</div>
You can’t perform that action at this time.