<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ZZ oo</title>
    <description>The latest articles on DEV Community by ZZ oo (@zz_oo_b49409b43e3e42b0457).</description>
    <link>https://dev.to/zz_oo_b49409b43e3e42b0457</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3456978%2Fbc056dd4-f11b-485f-bc31-744db93a87f3.jpg</url>
      <title>DEV Community: ZZ oo</title>
      <link>https://dev.to/zz_oo_b49409b43e3e42b0457</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zz_oo_b49409b43e3e42b0457"/>
    <language>en</language>
    <item>
      <title>How to write generic components (React, Vue)</title>
      <dc:creator>ZZ oo</dc:creator>
      <pubDate>Tue, 11 Nov 2025 06:55:00 +0000</pubDate>
      <link>https://dev.to/zz_oo_b49409b43e3e42b0457/how-to-write-generic-components-react-vue-pao</link>
      <guid>https://dev.to/zz_oo_b49409b43e3e42b0457/how-to-write-generic-components-react-vue-pao</guid>
      <description>&lt;p&gt;I want to write a component library that can be used directly in the React/Vue framework, but I don't want to write two copies of the code.&lt;/p&gt;

&lt;p&gt;I've consulted many resources, and generally speaking, the principle is to extract common logic and then write the corresponding React/Vue components.&lt;/p&gt;

&lt;p&gt;For example, introducing and using it like this&lt;/p&gt;

&lt;p&gt;Example：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// react&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ZButton&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;xxxxx/react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// vue&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ZButton&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;xxxxx/vue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm wondering if this means creating two separate component libraries, more than doubling the workload. Is there a way to directly import and use the components I write in both React and Vue?&lt;/p&gt;

&lt;p&gt;Example：Ideal code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// react/vue&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ZButton&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;xxxxx&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I've also seen some plugins that can compile my components into the version I want, but I'm worried about compatibility issues, and resolving compatibility issues might be more troublesome than writing the component itself.&lt;/p&gt;

&lt;p&gt;Is there any way to solve my problem?&lt;/p&gt;

&lt;p&gt;Thank you everyone!!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>vue</category>
    </item>
  </channel>
</rss>
