Skip to content

Instantly share code, notes, and snippets.

@HellMagic
Created April 14, 2016 03:44
Show Gist options
  • Select an option

  • Save HellMagic/463f05b14ae9f07804c1bf85825df386 to your computer and use it in GitHub Desktop.

Select an option

Save HellMagic/463f05b14ae9f07804c1bf85825df386 to your computer and use it in GitHub Desktop.
关于react的一些snippet
在react-router中获取context.router:
es5:
var someComponent = React.createClass({
getInitialState: function() {
var router = this.context.router;
}
})
但是在es6中:
class SomeConponent extends React.Component {
constructor(props, context) {
super(props);
var router = context.router;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment