Skip to content

Instantly share code, notes, and snippets.

@sami616
Last active April 25, 2019 12:54
Show Gist options
  • Save sami616/b67bb2df867c4a8a310928bb6cbad8af to your computer and use it in GitHub Desktop.
Save sami616/b67bb2df867c4a8a310928bb6cbad8af to your computer and use it in GitHub Desktop.
Medium post store.js
import React from 'react'
import { Counter } from './counter'
const providers = [<Counter.Provider />]
const Store = ({ children: initial }) =>
providers.reduce(
(children, parent) => React.cloneElement(parent, { children }),
initial
)
export { Store, Counter, Toggle }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment