Skip to content

Instantly share code, notes, and snippets.

@brookslybrand
Created January 25, 2019 16:16
Show Gist options
  • Select an option

  • Save brookslybrand/4b7aeb83f65c0a25ef67cc3c2e204f66 to your computer and use it in GitHub Desktop.

Select an option

Save brookslybrand/4b7aeb83f65c0a25ef67cc3c2e204f66 to your computer and use it in GitHub Desktop.
import React, { useState } from 'react'
import Dexie from 'dexie'
import Form from './Form'
const App = () => {
const [open, setOpen] = useState(true)
return (
<div style={{ margin: '2rem auto', width: '200px' }}>
<button onClick={() => setOpen(!open)}>{`${
open ? 'Close' : 'Open'
} Form`}</button>
{/* Pass in a new connection to the database when Form is first rendered */}
{open && <Form db={new Dexie('FormDatabase')} />}
</div>
)
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment