Skip to content

Instantly share code, notes, and snippets.

Harry Hedger hedgerh

Block or report user

Report or block hedgerh

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
View example.jsx
// prefer this
const ExamplePage = () => {
return (
<h1>Card 1!</h1>
<h2>A simple card!</h2>
hedgerh / PropValidation.tsx
Created Apr 29, 2019
Benefits of using Typescript with React #1: You get compile time prop validation and auto completion. This is especially helpful when working with a 3rd party UI library that you aren't 100% familiar with yet.
View PropValidation.tsx
import React from 'react';
interface IImage {
alt: string;
src: string;
interface IGalleryProps {
images: IImage[]
View duck.js
import { call, put, takeLatest } from 'redux-saga/effects'
import client from '../httpClient'
const createAction = (type) => (payload) => ({
const http = {
login: (credentials) =>'/login', credentials),
View a-typesafe-actions-duck.ts
import { call, put, takeLatest } from 'redux-saga/effects'
import { createStandardAction, ActionType, getType } from 'typesafe-actions'
import client from '../httpClient'
interface ILogin {
email: string;
password: string;
interface IUser {
hedgerh / index.tsx
Last active Mar 23, 2019 — forked from phd20/index.tsx
Working version of container that returns array of objects
View index.tsx
import { connect } from "react-redux";
import Dashboard from "./dashboard";
import { ApplicationState } from "../../store";
const mapStateToProps = (state: ApplicationState) => {
const sessions = sessionsArraySelector(state)
return {
user: state.oidc.user,
sessions: Object.values(sessions),
hedgerh / http.js
Last active Jan 22, 2019
Example http module with Axios
View http.js
import axios from 'axios'
export const http = axios.create({
baseUrl: 'https://localhost:3000',
headers: {
http.interceptors.response.use(response =>, err => throw new Error(err))
View HttpClient.js
import store from './store'
export default class HttpClient {
getUser() {
const token = store.getState()
// fetch and pass along your token
View actions.js
import httpClient from './httpClient'
const login = (email, password) => (dispatch) => {
return httpClient.login(email, password)
.then(response => {
httpClient.token = response.token
View inplay.jsx
import React, { Component } from "react";
import axios from "axios";
import moment from "moment";
export default class Feutred extends Component {
state = {
sports: [],
events: [],
isLoading: true,
errors: null
You can’t perform that action at this time.