demo-preview.tsx 472 字节
Newer Older
O
oasis-cloud 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import React, { useState } from 'react'
import './demo-preview.scss'
import { useHistory } from 'react-router-dom'

const DemoPreview = () => {
  const history = useHistory()
  const [URL, setURL] = useState(history.location.pathname)

  history.listen((location) => {
    setURL(location.pathname)
  })

  return (
    <div className="doc-demo-preview">
      <iframe src={`/react/demo.html#${URL}`} frameBorder="0"></iframe>
    </div>
  )
}

export default DemoPreview