Last active
October 4, 2018 08:08
-
-
Save jordanrios94/b15b48b6ee3b6069e58551fa671360ec to your computer and use it in GitHub Desktop.
React Decorators Example
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
import logo from './logo.svg'; | |
// hocs | |
import reaquireAuth from './requireAuth'; | |
/* | |
DECORATOR - (@) | |
- Cannot use them in create-react-app, unless inject them | |
- Support is wonky, spec is not final | |
- Can export only the decorated component | |
*/ | |
@requireAuth; | |
class Header extends Component { | |
render() { | |
// render code | |
} | |
} | |
export default Header; | |
/* | |
- Without of @requireAuth; | |
- One must do `export default requireAuth(Header)` | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment