Skip to content

Instantly share code, notes, and snippets.

@hatertron3000
Created October 5, 2019 22:42
Show Gist options
  • Save hatertron3000/f426f53911af379ad104768fc962762b to your computer and use it in GitHub Desktop.
Save hatertron3000/f426f53911af379ad104768fc962762b to your computer and use it in GitHub Desktop.
A JavaScript module that extends the PageClasses module from Cornerstone, and uses it to render a React component with context from the page.
import React from 'react'
import ReactDOM from 'react-dom'
import PageManager from '../page-manager'
const HelloWorld = (props) => (
<div>
<p>Hello World from React!</p>
<p>Here are my props:</p>
<pre>{JSON.stringify(props, null, 2)}</pre>
</div>
)
export default class ReactDemo extends PageManager {
onReady() {
const container = $('#root')[0]
ReactDOM.render(<HelloWorld context={this.context}/>, container)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment