View stealing.js
function A(name) {
this.name = name || 'Christiano';
return this.name;
}
function B() {
this.surname = 'Milfont';
this.getName = function() {
return `${this.name} - ${this.surname}`;
View install.sh
# with installed nvm
# Install SDK Android - https://facebook.github.io/react-native/docs/getting-started.html
# Appearance & Behavior → System Settings → Android SDK
# SDK Platforms: Android 6.0 (Marshmallow)
# Launch Standalone SDK Manager -> Tools -> 23.0.1
# Configure ~/.profile
export NVM_DIR="/Users/cmilfont/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
View Container.jsx
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import FormContainer from './form.jsx';
import List from './List.jsx';
/* Export function to unit tests */
export const TodoList = (todos, create) => (
<div>
<FormContainer submit={create} />
<List todos={todos} />
View asyncAwait.js
const models = require('./server/models');
const email = 'cmilfont@gmail.com';
async function fetchData(email) {
const [user, kind] = await Promise.all([
models.User.findOne({
where: { email }
}),
models.Kind.findOne({
View es7.js
import React from 'react';
import { connect } from 'react-redux';
import FormContainer from './container';
@connect(state => ({ openNewFeedback: state.openNewFeedback }))
export default class Form extends React.Component {
static propTypes = {
openNewFeedback: React.PropTypes.bool,
dispatch: React.PropTypes.func,
actions: React.PropTypes.any,
View babel.json
{
"presets": [
"es2015",
"react",
"stage-0"
],
"plugins": [
"transform-decorators-legacy",
[
"resolver",
View withdecorator.js
import React from 'react';
import { connect } from 'react-redux';
@connect((state) => ({
openNewFeedback: state.openNewFeedback,
}))
export default class Form extends React.Component {}
View withoutDecorator.js
import React from 'react';
import { connect } from 'react-redux';
class Form extends React.Component {}
const mapToProps = state => ({ openNewFeedback: state.openNewFeedback });
export default connect(mapToProps, Form);
View fatArrowFunctionEs7.js
class Form extends React.Component {
handleCreate = () => {
const { dispatch, actions } = this.props;
const type = actions.CREATE;
const payload = this.state;
dispatch({ type, payload });
this.handleClose();
}