Skip to content

Commit

Permalink
fix(VueWrapper): use ref to update listeners (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChibiBlasphem authored Jul 30, 2022
1 parent 293cbf6 commit 17b11aa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/wrappers/Vue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ export const VueWrapper = function VueWrapper<P>({
const rootEl = useRef<HTMLDivElement>(null);
const vueInstance = useRef<Vue | null>(null);
const childrenRef = useRef<ReactNode | undefined>();
const listenersRef = useRef<Record<string, any> | undefined>(on);

useEffect(() => {
childrenRef.current = children;
listenersRef.current = on;

if (vueInstance.current) {
Object.assign(vueInstance.current.$data, props);
Expand All @@ -79,7 +81,7 @@ export const VueWrapper = function VueWrapper<P>({
VUE_COMPONENT_NAME,
{
props: this.$data,
on,
on: listenersRef.current,
},
[wrapReactChildren(createElement, childrenRef)]
),
Expand Down

0 comments on commit 17b11aa

Please sign in to comment.