Developing React Widgets (build with Parcel)
This section describes how you can use React framework to develop your widgets, and build them with Parcel.
#
Creating the Project#
About this taskYou can create a React Web Component widget. The following instruction provides an example of creating a my-web-comp widget.
note
If you use VS code, ensure that your typescript coming with VS code is v4.0.2 or higher.
#
Procedure- Create the following folder structure:
Navigate to the src directory in the project folder.
In the src directory, create a new empty .tsx component file. For testing purposes, you can create SampleWidget.tsx.
Add the following code to the SampleWidget.tsx file:
In the same directory, create a new index.ts file.
Add the following code to the index.ts file:
- Import your SampleWidget React component into index.ts file and transform it into a customElement as follows:
#
Next stepWhen your project is ready as a Web Component, you must build it for later use.
#
Building the Project#
About this taskYou must build the project to use your widget in Avaya Workspaces.
#
Procedure- In the root project folder, create the package.json file with the following contents:
- Add tsconfig.json file with the following contents:
- Run the following commands to install necessary packages:
- Build your project running the following command:
- The bundled file my-web-app.js is in the dist folder. Host this folder using HTTP-server.
#
Next stepWhen your project is built, continue configuring the widget JSON file that you can import in the Widget Manager.