Last active
October 15, 2015 23:21
-
-
Save Polyrhythm/717c0d303837a90a4ccc to your computer and use it in GitHub Desktop.
Isomorphic component
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
export default class IsomorphicComponent extends React.Component { | |
// this only executes on the browser | |
componentDidMount() { | |
const wrapper = React.findDOMNode(this.refs.app); | |
wrapper.style.left = wrapper.getBoundClientRect().left + 'px'; | |
} | |
// this executes on the server and the browser | |
render() { | |
return ( | |
<div className="App" ref="App"></div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment