This file contains 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
// Imagine what would it be if connect, withRouter, injectIntl were child as function | |
export default ( | |
<Connect mapStateToProps={mapStateToProps} mapPropsToActions={actions}> | |
{ | |
(props) => ( | |
<WithRouter> | |
{ | |
(router) => ( | |
<InjectIntl> | |
{(intl => <SomeComonent intl={intl} router={router} {...props} />} |
This file contains 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 allUniqueChars(str) { | |
if(!str) return false; | |
let checker = 0; | |
let flagIndex; | |
const length = str.length; | |
for (let i = 0; i < length; i++) { | |
flagIndex = str[i].charCodeAt(0) - 'a'.charCodeAt(0); | |
if ((checker & (1 << flagIndex)) > 0) return false; |
This file contains 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 Counter extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {count: 0}; | |
this.incrementCounter = this.updateCounter.bind(this, 1); | |
this.decrementCounter = this.updateCounter.bind(this, -1); | |
} | |
render() { | |
return ( |
This file contains 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
var Select2 = React.createClass({ | |
componentDidMount: function() { | |
$(this._ref).select2({data: this.props.items}); | |
}, | |
render: function() { | |
return ( | |
<select | |
ref={ | |
function(input) { |
This file contains 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
var TextComponent = React.createClass({ | |
shouldComponentUpdate: function(nextProps, nextState) { | |
if (this.props.text === nextProps.text) return false; | |
return true; | |
}, | |
render: function() { | |
return <textarea value={this.props.text} />; | |
} | |
}); |
This file contains 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
var Container = React.createClass({ | |
getInitialState: function() { | |
return { | |
data: null, | |
fetching: false, | |
error: null | |
}; | |
}, | |
render: function() { |
This file contains 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
var Component = React.createClass({ | |
getDefaultProps: function() { | |
console.log('getDefaultProps'); | |
return { | |
title: "Basic counter!!!", | |
step: 1 | |
} | |
}, | |
getInitialState: function() { |
This file contains 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
var Counter = React.createClass({ | |
getDefaultProps: function() { | |
console.log('getDefaultProps'); | |
return { | |
title: 'Basic counter!!!' | |
} | |
}, | |
getInitialState: function() { | |
console.log('getInitialState'); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Hello React</title> | |
<script src="https://fb.me/react-15.0.2.js"></script> | |
<script src="https://fb.me/react-dom-15.0.2.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> | |
</head> | |
<body> |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Hello React</title> | |
<script src="https://fb.me/react-15.0.2.js"></script> | |
<script src="https://fb.me/react-dom-15.0.2.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> | |
</head> | |
<body> |
NewerOlder