Widget dependencies as js modules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 12:16 AM - edited 10-18-2023 12:59 AM
Hi experts,
I've a need to use the following script inside my widget
<script type="text/babel" data-presets="react,stage-3">
const { LocationMap } = window.geoJsLib;
const SampleMap = () => {
return (
<LocationMap
onSubmit={(location) => {
alert(`${location.latitude}, ${location.longitude}`);
}}
/>
);
};
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<SampleMap />
);
</script>
How would I go about including it in the widget? I tried creating a UI script and then adding that as a dependency in the widget, but then it throws the following error:
Uncaught SyntaxError: expected expression, got '<'
which suggests that it's not able to understand JSX (I've already included js files related to React as dependencies) but I'm thinking the <script type="text/babel"> part is where ServiceNow is having a hard time interpreting.
Is there a way to get this working?
script_5 is the UI script
UI script usage
Widget HTML
Client controller and Server scripts are empty (as in no lines of code)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 12:52 AM
Tagging some experts for better reach as I feel not many would be experiencing this problem
@Ankur Bawiskar @Dr Atul G- LNG @Rahul Priyadars @AnveshKumar M @Sandeep Rajput @Peter Bodelier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 12:44 AM
Any help please?