How to share javascript objects (instances) between TaskPane React App and function called from Word?

Morten Overgaard 0 Reputation points
2024-05-26T15:33:44.22+00:00

We are developing a Word Addin using React for the TaskPane which uses Zustand as the state management system.

We have been banging our heads against the wall for 2 days now to figure out how to let an action performed by the user (clicking a menu item in the context menu) get access and update the Zustand state managed by the React app in the TaskPane.

What we have setup is

  1. Shared javascript runtime - seems to work ok - not errors and are using the shared dom
  2. We can successfully call our javascript functions stored in commands.js from Word
  3. But is seems that the functions called in 2) are NOT running in the same javascript environment like the React App in the Taskpane. The state object from Zustand seems to be a different instance.

Can it be confirmed that this is possible. If not - how do you trigger React in the Taskpane do update ?

BR Morten

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
736 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
923 questions
0 comments No comments
{count} votes