<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>React Global Components</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118021983" />
  <subtitle>React Global Components</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118021983</id>
  <updated>2026-04-03T23:22:09Z</updated>
  <dc:date>2026-04-03T23:22:09Z</dc:date>
  <entry>
    <title>RE: React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123169725" />
    <author>
      <name>Tonni Alex</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=123169725</id>
    <updated>2025-01-13T16:32:36Z</updated>
    <published>2025-01-07T13:14:40Z</published>
    <summary type="html">&lt;p&gt;To reuse a React component like &lt;code&gt;Footer&lt;/code&gt; in multiple React
  portlets, you can define the &lt;code&gt;Footer&lt;/code&gt; component in a shared
  or common directory that is accessible to both portlets. Typically,
  you would create a separate folder, such as
  &lt;code&gt;src/components&lt;/code&gt;, and place the &lt;code&gt;Footer.js&lt;/code&gt;
  component there. Both portlets can then import the &lt;code&gt;Footer&lt;/code&gt;
  component from this centralized location. For instance, in both
  portlet files, you would import the &lt;code&gt;Footer&lt;/code&gt; component
  using a relative path like &lt;code&gt;import Footer from
  '../components/Footer'&lt;/code&gt;. This allows both portlets to use the
  same &lt;code&gt;Footer&lt;/code&gt; component without duplicating code.
  Additionally, if your application is large or uses micro-frontends,
  you might consider a package manager or module bundler that handles
  dependencies across different portlets, ensuring the component remains
  consistent across them.&lt;/p&gt;</summary>
    <dc:creator>Tonni Alex</dc:creator>
    <dc:date>2025-01-07T13:14:40Z</dc:date>
  </entry>
  <entry>
    <title>RE: React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118264300" />
    <author>
      <name>Babban Singh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118264300</id>
    <updated>2020-01-13T10:18:42Z</updated>
    <published>2020-01-13T10:18:42Z</published>
    <summary type="html">@Vahid, Were you able to achieve that, I am also trying to do that. I followed the link provided by Ivan, my .npmbundlerrc of module (test-react-portlet) is as below&lt;br /&gt; &amp;#34;config&amp;#34;: {&lt;br /&gt;        &amp;#34;imports&amp;#34;: {&lt;br /&gt;                &amp;#34;react-provider&amp;#34;: {&lt;br /&gt;                        &amp;#34;prop-types&amp;#34;: &amp;#34;15.6.2&amp;#34;,&lt;br /&gt;                        &amp;#34;react&amp;#34;: &amp;#34;16.8.6&amp;#34;,&lt;br /&gt;                          &amp;#34;react-dom&amp;#34;: &amp;#34;16.8.6&amp;#34;&lt;br /&gt;                  },&lt;br /&gt;                &amp;#34;common-component&amp;#34;: {&lt;br /&gt;                        &amp;#34;/&amp;#34;: &amp;#34;1.0.0&amp;#34;&lt;br /&gt;                  },&lt;br /&gt;                &amp;#34;redux-store&amp;#34;: {&lt;br /&gt;                    &amp;#34;/&amp;#34;: &amp;#34;1.0.0&amp;#34;&lt;br /&gt;                }&lt;br /&gt;        }&lt;br /&gt;    }my common-component  module contains one Button.js component and I am trying to use this Button component into test-react-portlet as i&lt;strong&gt;mport Button from &amp;#39;common-component&amp;#39; &lt;/strong&gt;but I am not able to do this. I am getting below error on browser console while going to use test-react-portlet in the page.Liferay AMD Loader: Unhandled failure : &amp;lt;script src=&amp;#34;&lt;a href="http://localhost:8080common-component@1.0.0/src/index.js?languageId=en_US"&gt;http://localhost:8080common-component@1.0.0/src/index.js?languageId=en_US&lt;/a&gt;&amp;#34;&amp;gt; while resolving modules.see the src url inside script &lt;a href="http://localhost:8080common-component@1.0.0/src/index.js?languageId=en_US"&gt;http://localhost:8080&lt;/a&gt; &lt;strong&gt;missing slash(/o/resolved-module/)&lt;/strong&gt; , I think it should be &lt;a href="http://localhost:8080/o/js/resolved-module/common-component@1.0.0/src/index.js?languageId=en_US"&gt;http://localhost:8080/o/js/resolved-module/common-component@1.0.0/src/index.js?languageId=en_US&lt;/a&gt;.Now what I have to do.</summary>
    <dc:creator>Babban Singh</dc:creator>
    <dc:date>2020-01-13T10:18:42Z</dc:date>
  </entry>
  <entry>
    <title>RE: React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118081823" />
    <author>
      <name>Vahid Kh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118081823</id>
    <updated>2019-12-14T20:59:33Z</updated>
    <published>2019-12-14T20:59:33Z</published>
    <summary type="html">No, a component can&amp;#39;t be imported from another portlet, I think their scopes are separate, &lt;br /&gt;​​​​​​​And as David said the best solution is creating npm package and importing it into various portlet.</summary>
    <dc:creator>Vahid Kh</dc:creator>
    <dc:date>2019-12-14T20:59:33Z</dc:date>
  </entry>
  <entry>
    <title>RE: React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118081471" />
    <author>
      <name>Vahid Kh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118081471</id>
    <updated>2019-12-14T20:25:52Z</updated>
    <published>2019-12-14T20:25:52Z</published>
    <summary type="html">Thanks my friend for all of your solutions </summary>
    <dc:creator>Vahid Kh</dc:creator>
    <dc:date>2019-12-14T20:25:52Z</dc:date>
  </entry>
  <entry>
    <title>RE: React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118037754" />
    <author>
      <name>Iván Zaera Avellón</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118037754</id>
    <updated>2019-12-10T09:20:38Z</updated>
    <published>2019-12-10T09:20:38Z</published>
    <summary type="html">You can see an example application with two widget portlets and three shared bundles that export React and Redux for the other two to consume here: &lt;a href="https://github.com/izaera/liferay-js-toolkit-showcase/tree/react"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="https://github.com/izaera/liferay-js-toolkit-showcase/tree/react"&gt;https://github.com/izaera/liferay-js-toolkit-showcase/tree/react&lt;/a&gt;&lt;br /&gt;That may inspire you on how to structure your solution.</summary>
    <dc:creator>Iván Zaera Avellón</dc:creator>
    <dc:date>2019-12-10T09:20:38Z</dc:date>
  </entry>
  <entry>
    <title>RE: React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118029722" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118029722</id>
    <updated>2019-12-09T15:04:03Z</updated>
    <published>2019-12-09T15:04:03Z</published>
    <summary type="html">I think so.&lt;br /&gt;Liferay has put a lot of effort in their loader to support things like that. You should be able to export your component in one bundle and require/import it in another module (or portlet). I have never tried it, but it should be possible.&lt;br /&gt;&lt;a href="https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/referencing-an-npm-modules-package"&gt;https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/referencing-an-npm-modules-package&lt;/a&gt;&lt;br /&gt;&lt;a href="https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/obtaining-dependency-npm-package-descriptors"&gt;https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/obtaining-dependency-npm-package-descriptors&lt;/a&gt;</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2019-12-09T15:04:03Z</dc:date>
  </entry>
  <entry>
    <title>RE: React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118024468" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118024468</id>
    <updated>2019-12-08T14:22:19Z</updated>
    <published>2019-12-08T14:22:19Z</published>
    <summary type="html">You can&amp;#39;t and you shouldn&amp;#39;t do this.&lt;br /&gt;&lt;br /&gt;Each portlet, by definition, should be able to render itself regardless of the page that it gets dropped on. There should be no dependencies on other portlets or even the global context because there is always a possibility those things won&amp;#39;t be there.&lt;br /&gt;&lt;br /&gt;A portlet is still just a portlet, even if it is written in React. Give them both the same footer component and let them render it.&lt;br /&gt;&lt;br /&gt;That said, you&amp;#39;re free to use your own NPM repository, build React components and publish them into your NPM repo, then each React portlet could depend upon that component from your repo, but that&amp;#39;s compile-time management of your components, not runtime management.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-12-08T14:22:19Z</dc:date>
  </entry>
  <entry>
    <title>React Global Components</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118021982" />
    <author>
      <name>Vahid Kh</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118021982</id>
    <updated>2019-12-08T13:34:47Z</updated>
    <published>2019-12-08T13:34:47Z</published>
    <summary type="html">Hello&lt;br /&gt;How can I reuse a &lt;strong&gt;React Component &lt;/strong&gt;in separate &lt;strong&gt;React portlets&lt;/strong&gt;?&lt;br /&gt;&lt;strong&gt;​​​​​​​&lt;/strong&gt;for more detail,  assume I have two &lt;strong&gt;react portlet &lt;/strong&gt;and they import the same Component named Footer,&lt;br /&gt;How and Where can I define Footer that can be used in both?</summary>
    <dc:creator>Vahid Kh</dc:creator>
    <dc:date>2019-12-08T13:34:47Z</dc:date>
  </entry>
</feed>
