Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
import {
HashRouter,
Route,
Link,
Switch,
} from 'react-router-dom';
import './App.css';
@knod
knod / RenderIfTrueExample.js
Created August 2, 2018 17:17
A safe way to do `<RenderIfTrue>`
// This is something we could possibly do more safely
const RenderIfTrue = function ({ shouldRender, children }) {
var ToRender = children;
if (shouldRender) {
return <ToRender />;
} else {
return null;
}
}; // End <RenderIfTrue>
@knod
knod / 1a-class.js
Last active October 16, 2017 22:03
Alternative code for Result if 1. it's kept as a class, 2. it's made into an object constructor, or 3 or 4, which are 1 and 2, but slightly rearranged.
/**
* All benefit programs' return value should be an instance of this class.
*
* @todo Implement `.expirationDate` to keep track of data that needs updating
* @todo Figure out how to access this jsdoc definition externally.
*
* @external
*
* @class
* @param {object} trial - Data to try out/validate
@knod
knod / expirationDateExample.js
Last active September 6, 2017 12:20
Expiring data and a possible way to handle it.
/** A way to stay aware of when any code used in this script will expire.
* For example, if dataObj1 is only valid till June 1, 2017, then
* this script should only be valid till then. After that the code
* should be changed to point to a new, valid, object.
* @exports {Date} expirationDate
*/
var expirationDate = new Date( 2018, 12, 31 );
// or it could calculate the expiration date based on all the objects it's pulling in
var calcExpirationDate = function() {