tachyon-ops / react_vue_ts

Vuera TS lib
22 stars 2 forks source link

Implemented method that obtain the internal reference of the React component. #4

Closed juanparati closed 1 year ago

juanparati commented 1 year ago

Actually is not possible to call React components methods from Vue, because the internal reference bind to the React component is missing. I implemented a way to obtain the internal reference calling the "reactRef" method.

Example:

<template>
<div>
    <MyReactComp ref="myReactComp" />
    <button type="button" @click="$refs.myReactComp.reactRef().reactMethodFooBar()">Call React Method</button>
</div>
</template>

<script>
import { ReactInVue } from "vuera-ts";
import { ReactComp } from "./ReactComp";

const MyReactComp = ReactInVue(MyReactComp);

export default {
  name: "VueApp",
};
</script>
tachyon-ops commented 1 year ago

$refs.myReactComp.reactRef().reactMethodFooBar() does the IDE figure the reactMethodFooBar type - so does the typing works with autocompletion?

edit: just noticed it doesn't.