Skip to content

Instantly share code, notes, and snippets.

@umbertoo
umbertoo / gist:9140727b743d730e7ff86f62e49cfcf9
Last active July 1, 2016 07:12 — forked from Borisboky/gist:b90b1a338ac9cfc5ba484d5aa1e11c3d
React router browser back button isn't working
import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as actionCreators from '../../actions/actionCreators';
import countries from '../../data/countries';
import users from '../../data/users';
import {browserHistory} from 'react-router';
import RegistrationFormStepOne from './registrationFormStepOne';
import RegistrationFormStepTwo from './registrationFormStepTwo';
var fs = require('fs');
var React = require('react');
var ReactDOMServer = require('react-dom/server');
var Manna = require('./Manna');
var Cog = require('./Cog');
var build = function(name, props) {
var size = props.size || 64;
@umbertoo
umbertoo / connect.js
Created June 17, 2016 18:30 — forked from gaearon/connect.js
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
//2 Define api , this.refs.dropDown.toggleMenu()
const DropDown = React.createClass({
getDefaultProps() {
return {initialIsOpen: false, onChange:()=>{}};
},
getInitialState() {
//set initial state from props
return {isOpen: this.props.initialIsOpen};
},
toggleMenu(){
// 1. Set initial state from props.isOpen, and modify state from parent component through componentWillReceiveProps
import React from 'react';
const DropDown = React.createClass({
getDefaultProps() {
return {isOpen: false, onChange:()=>{}};
},
getInitialState() {
//set initial state from props
return {isOpen: this.props.isOpen};
},