Hey there,
is there a way to use react hooks within the mdx file?
I'm trying to document a modal with docz like this:
name: Modal
---
import { Playground } from 'docz'
import Modal from './Modal'
import useToggle from '../../hooks/useToggle'
# Modal
<Playground>
const [toggleValue, toggle] = useToggle(false)
<Modal title="Modal title" visible={toggleValue} />
<button onClick={toggle}>Show Modal</button>
</Playground>
For sure,
<Playground>
{() => {
const [toggleValue, toggle] = useToggle(false)
return (
<>
<Modal title="Modal title" visible={toggleValue} />
<button onClick={toggle}>Show Modal</button>
</>
)
}}
</Playground>
NOTE: You can't have blank lines inside
NOTE: You can't have blank lines inside
This would be a great tip to add to the Docz docs! My search ended here.
Most helpful comment
For sure,