diff --git a/components/WalineComponent.js b/components/WalineComponent.js index 62e65c0e..567dd1d9 100644 --- a/components/WalineComponent.js +++ b/components/WalineComponent.js @@ -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
}