Created
May 16, 2018 02:13
-
-
Save sal-pal/1fb8ce1a4bd9a7bca527f34a64fbbdb6 to your computer and use it in GitHub Desktop.
This file contains 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 React from "react" | |
import PropTypes from "prop-types" | |
import updateJsonSpec from "../plugins/deep-linking/spec-wrap-actions.js" | |
export default class App extends React.Component { | |
getLayout() { | |
let { getComponent, layoutSelectors } = this.props | |
const layoutName = layoutSelectors.current() | |
const Component = getComponent(layoutName, true) | |
return Component ? Component : ()=> <h1> No layout defined for "{layoutName}" </h1> | |
} | |
componentDidMount() { | |
const system = this.props | |
const hashChngHndlr = function() { | |
const system = this.props | |
const ori = system.specActions.updateJsonSpec | |
updateJsonSpec(ori, system) | |
} | |
window.onhashchange = hashChngHndlr.bind(this) | |
} | |
render() { | |
const Layout = this.getLayout() | |
return ( | |
<Layout/> | |
) | |
} | |
} | |
App.propTypes = { | |
getComponent: PropTypes.func.isRequired, | |
layoutSelectors: PropTypes.object.isRequired, | |
} | |
App.defaultProps = { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment