简体   繁体   中英

How to convert SPFX (ReactJS) project to ReactJS?

How to convert the SPFx(ReactJs) Project to ReactJS? Or would it possible to make use of the dist/lib folder binaries to include in the newly created ReactJs Project as Component and reuse the existing SPFx components?

In theory it is possible (You can use gulp build command to generate a library [es module]). But I don't think it will be possible to reuse it outside of SPFx due to dependency on @microsoft libraries (for example @microsoft/sp-http) and of course lack of SPWebPartContext.

Even if You could somehow include the @microsoft libraries in Your build and try to run it outside of SharePoint You will run into few issues on runtime, for example to get Graph API token it will try to call a method to convert SPO token to Graph API token (this is over-simplification of course) and there is no SPO token available as You are not in SPO context.

Hope that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM