Skip to content

Instantly share code, notes, and snippets.

View pmonty's full-sized avatar

pmonty pmonty

  • Melbourne, Australia
View GitHub Profile
@pmonty
pmonty / useAxios.js
Created March 15, 2019 00:26
useAxious
import axios from 'axios'
import { useEffect, useReducer, useState } from 'react'
const initialResponse = { response: null, error: null, loading: false }
function responseReducer(state, action) {
switch (action.type) {
case 'INIT':
return { response: null, error: null, loading: true }
case 'SUCCESS':
@pmonty
pmonty / withFormik.tsx
Created July 9, 2018 05:19
withFormik issue
export interface IProfilePageProps {
appStore?: AppStore;
profileStore?: ProfileStore;
}
@inject('appStore', 'profileStore') @observer
class ProfileForm extends React.Component<FormikProps<any> & IProfilePageProps, {}> {
public componentDidMount() {
this.props.appStore.setPageTitle('Profile', 'View and edit your personal details');
if (this.props.profileStore.profile.loading) {