Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: How can I import Liferay Portal library to my react project?
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.
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.
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.
Try using window.Liferay.ThemeDisplay
.
Already tried, still not working unfortunately.
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
Powered by Liferay™