Skip to content

Instantly share code, notes, and snippets.

@Polyrhythm
Last active October 15, 2015 23:21
Show Gist options
  • Save Polyrhythm/717c0d303837a90a4ccc to your computer and use it in GitHub Desktop.
Save Polyrhythm/717c0d303837a90a4ccc to your computer and use it in GitHub Desktop.
Isomorphic component
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