Skip to content

Instantly share code, notes, and snippets.

@giladaya
giladaya / README.md
Last active December 23, 2019 15:14
Simple hook that allows to "persist" values when navigating between routes, using Redux

DESCRIPTION

Simple custom hook that allows to "persist" values when navigating between routes.
Uses Redux for holding the state so all Redux tools and features are available.

SETUP

Make sure that Redux is setup with the project.
Then, just add the reducer to the global composite reducer:

@giladaya
giladaya / NestSelect3.tsx
Created March 30, 2019 16:23
React recursive nested selection component
import * as React from 'react';
const NO_SELECT = '';
interface OptionsObj {
[key: string]: OptionsObj | string[]
}
type Options = OptionsObj | string[];
@giladaya
giladaya / .env
Last active January 19, 2022 08:17
.env support for webpack - based on code from create-react-app
# example of a config value
REACT_APP_EXAMPLE_VAL=1234
@giladaya
giladaya / gist:dd4e761ce20a4da802c8
Created August 18, 2015 14:24
if we are on a subdomain, change links on page that point to the main domain to point to the same path in the subdomain
(function subdomain() {
var hostParts = location.host.split('.');
if (hostParts.length < 3) {
return;
}
var subdomain = hostParts[0];
var domain = hostParts.slice(-2).join('.');
var a = document.getElementsByTagName('a'); // grab every link on the page
var prefix = 'http://'+domain;