legacy-knowledge-base
公開されました Sep. 10, 2025

Custom DDM field React error #321

written-by

Balázs Létai

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

Issue

Environment

  • Liferay DXP Quarterly Releases

Resolution

  • The issue could indicate that multiple instances of React are being loaded.
  • Since Liferay includes React by default, this issue may occur if your DDM field or custom module is also bundling a separate version of React.
  • One of the loaded react could be bundled in the module or loaded from CDN or other cache.
  • Review cache configuration and make sure CDN bundles the module with using react as external import.
  • When the module bundled using webpack, e.g.:

    module.exports = {
      // ...
      externals: {
        react: 'React',
        'react-dom': 'ReactDOM',
      },
    };

https://liferay.dev/blogs/-/blogs/using-webpack-and-es-modules-in-liferay-dxp

  • Similar achievable in vite:

    build: {
        outDir: 'build/vite',
        rollupOptions: {
          external: [
            'react',
            'react-dom',
            'react-hook-form',
            /^(?!@clayui\/css)@clayui.*$/,
          ],
        }

    https://liferay.dev/blogs/-/blogs/sharing-javascript-code-and-libraries 

  • Liferay official example: Adapting the C2P9 Slider for Liferay DXP 2025.Q2

    build": "esbuild ./src/main/resources/META-INF/resources/C2P9/Slider.es.js --outfile=./build/resources/main/META-INF/resources/__liferay__/index.js --bundle --format=esm --external:react --external:react-dom --external:@liferay/dynamic-data-mapping-form-field-type --loader:.js=jsx"
did-this-article-resolve-your-issue

legacy-knowledge-base