Skip to content

Instantly share code, notes, and snippets.

View dane-stevens's full-sized avatar

Dane Stevens dane-stevens

View GitHub Profile
import React from "react";
import PropTypes from "prop-types";
// Create a State Render Prop Component
class State extends React.Component {
constructor(props) {
super(props);
// Initialize state from init prop
this.state = this.props.init;
import React from "react";
const Button = ({ children }) => <button>{children}</button>;
export default Button;
import React from "react";
class Button extends React.Component {
constructor(props) {
super(props);
this.state = {
disabled: false
};
this.handleClick = this.handleClick.bind(this);
}
import React from "react";
// Import State RenderProp Component
import State from "./State";
const Button = ({ children }) => (
// Wrap <Button /> with <State />
// Pass init prop to set the default state
<State init={{ disabled: false }}>
// <State />'s render function returns (function, state)
export const monroeShocktober = {
type: 'MAX_REWARD',
// Monroe buy 4 for the price of 3
filters: [
{
qualifier: {
match: "ALL",
conditions: [
@dane-stevens
dane-stevens / TueriImg.js
Last active March 19, 2019 15:14
Tueri - Image Component Simple
import React from 'react'
import PropTypes from 'prop-types'
import { TueriContext } from './Provider'
import kebabCase from 'lodash.kebabcase'
class Img extends React.Component {
constructor(props) {
super(props)
this.state = {
class Img extends React.Component {
constructor(props) {
super(props)
this.state = {
width: 0
}
this.imgRef = React.createRef()
}
class Img extends React.Component {
constructor(props) {
...
this.window = typeof window !== 'undefined' && window
this.isWebpSupported = this.isWebpSupported.bind(this)
}
...
class Img extends React.Component {
constructor(props) {
...
this.state = {
...
isInViewport: false
lqipLoaded: false
}
...
class Img extends React.Component {
constructor(props) {
...
this.state = {
...
fullsizeLoaded: false
}
...