Share via

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

Microsoft 365 and Office | Development | Office JavaScript API
Microsoft 365 and Office | Word | For business | Windows
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.