Skip to content

Instantly share code, notes, and snippets.

@sal-pal
Created May 16, 2018 02:13
Show Gist options
  • Save sal-pal/1fb8ce1a4bd9a7bca527f34a64fbbdb6 to your computer and use it in GitHub Desktop.
Save sal-pal/1fb8ce1a4bd9a7bca527f34a64fbbdb6 to your computer and use it in GitHub Desktop.
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 &quot;{layoutName}&quot; </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