Merge pull request #274 from tangly1024/feat_comment_valine

hotfix-waline-cors
This commit is contained in:
tangly1024
2022-05-27 13:23:36 +08:00
committed by GitHub

View File

@@ -13,31 +13,22 @@ export const WalineComponent = (props) => {
const containerRef = React.createRef()
const router = useRouter()
const updateWaline = url => {
walineInstanceRef.current?.update(props)
}
React.useEffect(() => {
walineInstanceRef.current = init({
...props,
el: containerRef.current,
serverURL: BLOG.COMMENT_WALINE_SERVER_URL
})
return () => walineInstanceRef.current?.destroy()
}, [])
const updateWaline = url => {
walineInstanceRef.current?.update(props)
}
React.useEffect(() => {
walineInstanceRef.current?.update(props)
router.events.on('routeChangeComplete', updateWaline)
return () => {
walineInstanceRef.current?.destroy()
router.events.off('routeChangeComplete', updateWaline)
}
}, [])
React.useEffect(() => {
}, [])
return <div ref={containerRef} />
}