diff --git a/example/App.js b/example/App.js index 4488600..74c516a 100644 --- a/example/App.js +++ b/example/App.js @@ -4,36 +4,30 @@ import { Component, h, render } from 'preact' let document function App({ rootTag }) { + // Register native components as dom compatible elements registerNativeDOM() + // create a dom with the root container from react native document = createDOM(rootTag) global.document = document - onRender() + // render a preact component to the above DOM + render(h(RenderableComponent, {}), document) return null } -function onRender() { - try { - const jsx = h(RenderableComponent, {}) - render(jsx, document) - } catch (err) { - console.log(err) - } -} - class RenderableComponent extends Component { state = { count: 0, } componentDidMount() { - setInterval(()=>{ - this.setState({ count: this.state.count + 1 }) - },1000) + setInterval(() => { + this.setState({ count: this.state.count + 1 }) + }, 1000) } render() { - return h('Text', {}, `Count ${this.state.count}`) + return h('SafeAreaView', {}, h('Text', {}, `Count ${this.state.count}`)) } } -export default App +export default App \ No newline at end of file