Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use create-react-app with Office.js #691

Closed
tong-1324 opened this issue Jan 17, 2019 — with docs.microsoft.com · 2 comments
Closed

Use create-react-app with Office.js #691

tong-1324 opened this issue Jan 17, 2019 — with docs.microsoft.com · 2 comments
Assignees
Labels
Type: doc request Request for new documentation or updates/enhancements to existing documentation

Comments

Copy link

tong-1324 commented Jan 17, 2019

I am trying to add Office.js to my react project created by create-react-app, which I believe is the most popular way to start a react project. After I add the CDN link to Office.js and set up the Office.initialize in my project, it keeps failing to compile with an error says "Office is not defined no-undef" and "Excel is not defined no-undef".

After some investigation, I find out the cause is that the default configuration of Eslint in create-react-app does not allow us to use global variable in the react components. Variables like “Office” and “Excel” in office.js are all treated as global variables in react components, so we keep seeing that error. To fix the issue, we need to add “/* global Excel, Office */” at the beginning of the react components files. It allows those components to access global variable. We could also fix the issue by customizing the Eslint config.

I think we could improve our documentation by mentioning the problem above. Create-react-app is a project with 60,000+ stars on GitHub, and I think we should provide some documentation here to help developers using Office.js with that. At least we could mention the problem above in this documentation. It should save a lot of time for other developers who want to build office applications with create-react-app.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@Rick-Kirkham Rick-Kirkham added area: add-ins Type: doc request Request for new documentation or updates/enhancements to existing documentation labels Jan 17, 2019
@Rick-Kirkham Rick-Kirkham self-assigned this Jan 17, 2019
@Rick-Kirkham
Copy link
Contributor

Rather than having devs change their favorite eslint settings, I think it would be better to have them add the special comment to component files. I'll update the instructions for that.

@Rick-Kirkham
Copy link
Contributor

The article is updated in the source. It should be published live in the next day or two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: doc request Request for new documentation or updates/enhancements to existing documentation
Projects
None yet
Development

No branches or pull requests

2 participants