This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use the following function to generate random reactions and filter the output | |
// tweak LIMIT if you experience sluggishness | |
// Read below for more instructions | |
const LIMIT = 20 | |
function randomAPIresponse() { | |
function shuffle(array) { | |
for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]];} | |
return array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addCss(fileName) { | |
var head = document.head; | |
var link = document.createElement("link"); | |
link.type = "text/css"; | |
link.rel = "stylesheet"; | |
link.href = fileName; | |
head.appendChild(link); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'React' | |
function asyncComponent(getComponent) { | |
return class AsyncComponent extends React.Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chain = startTransaction.chain() | |
const success = () => { | |
startTransaction.end() | |
res.sendStatus(204) | |
} | |
const error = (error) => { | |
startTransaction.end() | |
res.sendStatus(500) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bound to a button onClick method | |
let validation = Validator({ | |
name: ReactDOM.findDOMNode(this.refs.name).value, | |
company: ReactDOM.findDOMNode(this.refs.company).value, | |
email: ReactDOM.findDOMNode(this.refs.email).value, | |
}, new Map([ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Examples | |
Type.is.function(() => {}) // true | |
Type.is.array({}) // false | |
Type.is.not.array([]) // false | |
Type.is.not.object(null) // true | |
Type.detect({}) // "object" | |
Type.detect("string") // "string" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import utils from './utils' | |
import AppDispatcher from 'AppDispatcher' | |
import Request from './Request' | |
import NotificationManager from './NotificationManager' | |
import SessionManager from './SessionManager' | |
import ResourceStore from './ResourceStore' | |
const context = { | |
AppDispatcher, | |
Request, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Draft.js came out, thank you again Facebook, Easy to implement, | |
but i struggled with how it could work with persisting it backend and then parseing it. | |
The flow looks like this | |
1. DraftJsEditor has set state with an immutable-js obj contaning the state of the contentfield | |
2. we transform it to json via: | |
*/ | |
let data = { | |
content: JSON.stringify(convertToRaw(this.state.content.getCurrentContent())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
export default class Main extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { | |
return <div>It works</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return React.cloneElement( | |
this.props.children, | |
this.props.passThisToChild |
NewerOlder