Created
April 14, 2016 03:44
-
-
Save HellMagic/463f05b14ae9f07804c1bf85825df386 to your computer and use it in GitHub Desktop.
关于react的一些snippet
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
| 在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