Reputation: 470
I'm developing a Word Add-in app in my pre-existing React project.
I installed Office.js with the following command from @microsoft/office-js.
npm i @microsoft/office-js
Now I'm trying to use the Office.js object like Office.context.document.getFileAsync()
but I don't know how to import it and use it in the React project.
Does anyone know how to do this?
Upvotes: 0
Views: 1614
Reputation: 9684
Usually, you load the Office JavaScript Library from the CDN with a <script>
tag in the home page. See for exmaple the index.html and main.tsx files in this sample: https://github.com/OfficeDev/Word-Add-in-GettingStartedFabricReact
If you want to use the library locally, you should be able to import it the same way you would import any other @vendor/library.js
from the node-modules
folder.
Upvotes: 1