Method | Side effects1 | State updates2 | Example uses |
---|---|---|---|
Mounting | |||
componentWillMount |
✓ | Constructor equivalent for createClass |
|
render |
Create and return element(s) | ||
componentDidMount |
✓ | ✓ | DOM manipulations, network requests, etc. |
Updating | |||
componentWillReceiveProps |
✓ | Update state based on changed props |
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'; | |
import Helmet from 'react-helmet'; | |
import { renderToString, renderToStaticMarkup } from 'react-dom/server'; | |
import { StaticRouter } from 'react-router-dom'; | |
import { AsyncComponentProvider, createAsyncContext } from 'react-async-component'; | |
import asyncBootstrapper from 'react-async-bootstrapper'; | |
import config from '../../../config'; | |
import ServerHTML from './ServerHTML'; |
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 MyEditor { | |
onPaste = (_event, paste, state) => { | |
if (paste.type === "text" && isUrl(paste.text) && state.isCollapsed) { | |
return ( | |
state | |
.transform() | |
.insertText(paste.text) | |
.extend(0 - paste.text.length) | |
.wrapInline({ | |
type: "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 { Plugin } from 'uppy'; | |
export default class ReduxEmitter extends Plugin { | |
constructor(core, opts) { | |
super(core, opts); | |
this.type = 'redux'; | |
this.id = 'ReduxEmitter'; | |
this.title = 'Redux Emitter'; | |
// set default options | |
const defaultOptions = {}; |
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' | |
import Portal from 'react-portal' | |
import getOffsets from 'positions' | |
import { findDOMNode } from 'slate' | |
/** | |
* No-op. | |
* | |
* @type {Function} |
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
module AMS | |
module V09 | |
class Serializer < ActiveModel::Serializer | |
def serializable_hash(adapter_options = nil, | |
options = {}, | |
adapter_instance = self.class.serialization_adapter_instance) | |
object.nil? ? nil : super | |
end | |
end |
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' | |
import Portal from 'react-portal' | |
class LinkBlock extends React.Component { | |
constructor (props) { | |
super(props) | |
this.state = { | |
href: this.props.node.data.get('href'), | |
showingPopup: false, | |
popup: null, |
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
export function login(loginHandle, password) { | |
return { | |
types: [LOGIN_REQUEST, LOGIN_SUCCESS, LOGIN_FAILURE], | |
promise: (api) => api.post('/auth/login', { login: loginHandle, password }).then(response => { | |
setAuthCookie(response.token); // side effect pre success dispatch | |
return response; | |
}), | |
then: (response) => { | |
postLoginRedirect(browserHistory.push, response.user, response.organisation); // side effect post success dispatch | |
}, |
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
FROM node:5.1.1 | |
#Install AWS CLI | |
RUN apt-get update | |
RUN apt-get install -y python-pip | |
RUN pip install awscli | |
RUN mkdir -p /root/.aws | |
RUN echo '[default]' > /root/.aws/config | |
RUN echo 'output = json' >> /root/.aws/config | |
RUN echo 'region = us-east-1' >> /root/.aws/config |
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
require "net/http" | |
def start_server | |
# Remove the X to enable the parameters for tuning. | |
# These are the default values as of Ruby 2.2.0. | |
@child = spawn(<<-EOC.split.join(" ")) | |
XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0 |