RE: RE: How can I import Liferay Portal library to my react project?

تم تعديل Jamie Sammons منذ 3 سنوات من الدقائق. New Member المشاركات: 6 تاريخ الإنضمام: 9‏/3‏/23 المشاركات الحديثة

Hello everyone, i would like to use the command Liferay.ThemeDisplay in my react application but if i try to install the library liferay-portal or frontend-js-web with npm I get errors, so i tried to install directly from github with the command npm install https://github.com/liferay/liferay-portal but is still not working.

I searched on the net and the library that i have to use should be this one, so how can i add to my react application?


Thanks everyone.

thumbnail
تم تعديل Jamie Sammons منذ 3 سنوات من الدقائق. Liferay Legend المشاركات: 1555 تاريخ الإنضمام: 24‏/9‏/09 المشاركات الحديثة

The Liferay object is added to all Liferay pages as a global variable, so you should be able to just access it directly when your React application is added to a Liferay page. No need to import anything.

تم تعديل Jamie Sammons منذ 3 سنوات من الدقائق. New Member المشاركات: 6 تاريخ الإنضمام: 9‏/3‏/23 المشاركات الحديثة

I've already tried to use it without import anything but it didn't work. I have the error 'Liferay’ is not defined that's why i thought i had to import something. How can I solve this error? Thanks.

thumbnail
تم تعديل Jamie Sammons منذ 3 سنوات من الدقائق. Liferay Legend المشاركات: 14933 تاريخ الإنضمام: 2‏/9‏/06 المشاركات الحديثة

Try using window.Liferay.ThemeDisplay.

تم تعديل Jamie Sammons منذ 3 سنوات من الدقائق. New Member المشاركات: 6 تاريخ الإنضمام: 9‏/3‏/23 المشاركات الحديثة

Already tried, still not working unfortunately.

تم تعديل Jamie Sammons منذ 2 سنوات من الدقائق. New Member المشاركات: 6 تاريخ الإنضمام: 8‏/2‏/23 المشاركات الحديثة

Hi Gregorio,

in Liferay Github you can find some examples how it works. As I unterstand you try to run something like coded in this client extension:

https://github.com/liferay/liferay-portal/tree/master/workspaces/liferay-sample-workspace/client-extensions/liferay-sample-custom-element-2