Skip to content

Instantly share code, notes, and snippets.


Darryl Dexter DarrylD

Block or report user

Report or block DarrylD

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
busypeoples / TypeScriptFundamentals.ts
Last active May 19, 2019
TypeScript Fundamentals For JavaScript Developers
View TypeScriptFundamentals.ts
// TypeScript Fundamentals For JavaScript Developers
Tutorial for JavaScript Developers wanting to get started with TypeScript.
Thorough walkthrough of all the basic features.
We will go through the basic features to gain a better understanding of the fundamentals.
You can uncomment the features one by one and work through this tutorial.
If you have any questions or feedback please connect via Twitter:
A. Sharif :
MicheleBertoli / App.jsx
Last active Aug 30, 2018
React Automata
View App.jsx
import React from 'react'
import { Action, withStatechart } from 'react-automata'
const statechart = {
initial: 'idle',
states: {
idle: {
on: {
FETCH: 'fetching',
View FiniteMachine.js
import React, { Component } from "react"
import { Machine } from "xstate"
import * as PropTypes from "prop-types"
class FiniteMachine extends Component {
machine = Machine(this.props.chart)
state = {
data: this.props.reducer(undefined, { type: "@init" }),
machineState: this.machine.getInitialState()
kitze / conditionalwrap.js
Created Oct 25, 2017
one-line React component for conditionally wrapping children
View conditionalwrap.js
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
wrap={children => <a href="/">{children}</a>}
Mohamed3on /
Last active Oct 3, 2019
Run prettier on all JS files in a directory
  1. Install prettier
  2. Make a .prettierignore file, and add directories you'd like prettier to not format, for example: **/node_modules
  3. Run prettier --write "**/*.js" *Don't forget the quotes.
  4. Optional: if you want to format JSON/SCSS files too, replace js with json/scss.
View example2.js
function getErroringPromise() {
console.log('getErroringPromise called');
return Promise.reject(new Error('sad'));
.subscribe(x => console.log);
// logs "getErroringPromise called" 4 times (once + 3 retries), then errors
EmielM / rollup.config.js
Created Jul 27, 2017
react-native rollup bundle attempt
View rollup.config.js
import fs from 'fs';
import path from 'path';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript';
import replace from 'rollup-plugin-replace';
function findVersion(file, extensions) {
for (let e of extensions) {
DimitryDushkin / example-of-react-router-query-utils.jsx
Created Feb 8, 2017
Example of using react-router query utils
View example-of-react-router-query-utils.jsx
import Modal from 'react-modal';
import { addQuery, removeQuery } from './utils-router.js';
const OPEN_MODAL_QUERY = 'openModal';
function SomeComponent({ location }) {
return <div>
<button onClick={ () => addQuery({ OPEN_MODAL_QUERY : 1 })}>Open modal</button>
isOpen={ location.query[OPEN_MODAL_QUERY] }
DimitryDushkin / react-router-queyry-utils.js
Last active Dec 5, 2019
React router utility functions to add and remove queries
View react-router-queyry-utils.js
import { browserHistory } from 'react-router';
* @param {Object} query
export const addQuery = (query) => {
const location = Object.assign({}, browserHistory.getCurrentLocation());
Object.assign(location.query, query);
You can’t perform that action at this time.