Skip to content

Two different ways to use React with Liferay Portal

Notifications You must be signed in to change notification settings

dnebinger/liferay-react-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

liferay-react-demo

Setup

Liferay Portal

Need Liferay 7.1+ and the com.liferay.frontend.js.portlet.extender module

Deploying the Portlet

  1. Navigate to portlet
  2. Install: npm install
  3. Set liferayDir in .npmbuildrc
  4. Set contentSpaceId in liferay-config
  5. Deploy: npm run deploy

Starting Standalone

  1. Navigate to standalone
  2. Install: npm install
  3. Create OAuth2 application in Portal. Portal OAuth2 Setup
  4. Set clientId(from OAuth app) and contentSpaceId in liferay-config
  5. Start: npm run start

Caveats

Portlet

  • Have to disable SPA module (Liferay Frontend JS SPA Web)
  • Had to use hash routing because browser history routing breaks after page reload.
    • It'd be great if there was some sort of manifest that the module could provide that would determine which routes portal should ignore.
  • Unable to use custom webpack loaders or custom build process
  • Unable to use dynamic imports and code splitting
  • Requires some internal knowledge of liferay-npm-build-support and liferay-npm-bundler

Standalone

Overall Thoughts

  • /o/api was great for GET requests and reading resources but wasn't fully baked out enough for POSTing and PUTing.
  • /o/api was easy to discover by navigating through the urls
  • /api/jsonws filled in for the gaps that /o/api was missing
  • Adding a file via Liferay.Service didn't work, which means I had to create a separate axios request. See Upload Page
  • There were a lot of required parameters that I didn't find helpful when using /api/jsonws.
  • I couldn't get create-react-app working in the portlet context.I tried adding the proper packages to the package.json so that it deployed as a portlet but the build version of CRA seemed inconsistant with what liferay and the bundler wanted.

About

Two different ways to use React with Liferay Portal

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.6%
  • HTML 1.3%
  • CSS 0.1%