fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

another spfx with latest office-ui-fabric-react issue

Open peterremote1980 opened this issue 8 years ago • 13 comments

If i delete , everything back to work.

{
	"name": "coding-news",
	"version": "0.0.1",
	"private": true,
	"engines": {
		"node": ">=0.10.0"
	},
	"scripts": {
		"build": "gulp bundle",
		"clean": "gulp clean",
		"test": "gulp test"
	},
	"dependencies": {
		"@microsoft/sp-core-library": "~1.4.1",
		"@microsoft/sp-lodash-subset": "~1.4.1",
		"@microsoft/sp-office-ui-fabric-core": "~1.4.1",
		"@microsoft/sp-webpart-base": "~1.4.1",
		"@types/react": "16.3.17",
		"@types/react-dom": "16.0.6",
		"@types/webpack-env": ">=1.12.1 <1.14.0",
		"chart.js": "2.7.2",
		"jquery": "^3.3.1",
		"office-ui-fabric-react": "^6.9.0",
		"react": "16.4.0",
		"react-dom": "16.4.0",
		"react-chartjs": "^1.2.0"
	},
	"devDependencies": {
		"@microsoft/sp-build-web": "~1.4.1",
		"@microsoft/sp-module-interfaces": "~1.4.1",
		"@microsoft/sp-webpart-workbench": "~1.4.1",
		"gulp": "~3.9.1",
		"@types/chai": "4.1.3",
		"@types/mocha": "5.2.2",
		"ajv": "6.5.1"
	}
}
import * as React from 'react';
import styles from './CodingNews.module.scss';
import { ICodingNewsProps } from './ICodingNewsProps';
import { escape } from '@microsoft/sp-lodash-subset';
import { DefaultButton, IButtonProps } from 'office-ui-fabric-react/lib/Button';
import { Label } from 'office-ui-fabric-react/lib/Label';

export default class CodingNews extends React.Component<ICodingNewsProps, {}> {
	public render(): React.ReactElement<ICodingNewsProps> {
		return (
			<div className={styles.codingNews}>
				<div className={styles.container}>
					<div className={styles.row}>
						<div className={styles.column}>
							<span className={styles.title}>Welcome to SharePoint!</span>
							<p className={styles.subTitle}>Customize SharePoint experiences using Web Parts.</p>
							<p className={styles.description}>{escape(this.props.description)}</p>
							<a href="https://aka.ms/spfx" className={styles.button}>
								<span className={styles.label}>Learn more</span>
							</a>

							<DefaultButton
								text="Button"
							/>
						</div>
					</div>
				</div>
			</div>
		);
	}
}

Error:

[SPLoaderError.loadComponentError]:
***Failed to load component "aff94c45-b9d9-4d82-b0ed-1756e97de86a" (CodingNewsWebPart).
Original error: ***Failed to load entry point from component "aff94c45-b9d9-4d82-b0ed-1756e97de86a" (CodingNewsWebPart).
Original error: Error loading https://component-id.invalid/aff94c45-b9d9-4d82-b0ed-1756e97de86a_0.0.1
	__WEBPACK_IMPORTED_MODULE_0__uifabric_merge_styles__["a" /* Stylesheet */].getInstance().onReset is not a function. (In '__WEBPACK_IMPORTED_MODULE_0__uifabric_merge_styles__["a" /* Stylesheet */].getInstance().onReset(resetIds)', '__WEBPACK_IMPORTED_MODULE_0__uifabric_merge_styles__["a" /* Stylesheet */].getInstance().onReset' is undefined)

***INNERERROR:
***Failed to load entry point from component "aff94c45-b9d9-4d82-b0ed-1756e97de86a" (CodingNewsWebPart).
Original error: Error loading https://component-id.invalid/aff94c45-b9d9-4d82-b0ed-1756e97de86a_0.0.1
	__WEBPACK_IMPORTED_MODULE_0__uifabric_merge_styles__["a" /* Stylesheet */].getInstance().onReset is not a function. (In '__WEBPACK_IMPORTED_MODULE_0__uifabric_merge_styles__["a" /* Stylesheet */].getInstance().onReset(resetIds)', '__WEBPACK_IMPORTED_MODULE_0__uifabric_merge_styles__["a" /* Stylesheet */].getInstance().onReset' is undefined)
***CALLSTACK:
SPError@https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:10183:33
SPLoaderError@https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:4211:32
SPLoaderError@[native code]
buildErrorWithVerboseLog@https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:3821:146
https://localhost:4321/node_modules/@microsoft/sp-loader/dist/sp-loader-assembly_en-us.js:7952:61
promiseReactionJob@[native code]

peterremote1980 avatar Jun 12 '18 17:06 peterremote1980

i encountered the same issue :(

lling1105 avatar Jun 14 '18 02:06 lling1105

@SriDeshpande can you take a look at this?

cliffkoh avatar Jun 14 '18 20:06 cliffkoh

I have the same issue - OfficeUIFabricReact not working with SPFx 1.5.0 :(

gosiaborzecka avatar Jun 15 '18 09:06 gosiaborzecka

Same issue with spfx 1.5.0

alexandervonmalachowski avatar Jun 16 '18 03:06 alexandervonmalachowski

spfx is not well tested version

peterremote1980 avatar Jun 16 '18 08:06 peterremote1980

I don't know if this is a Office UI Fabric React, SPFX or Office Online problem.

The problem is Office 365 loads an "spofiles_mini.js" file, which includes an old version of the mergeStyle module.

In this module there is a function "getInstance()" in the Stylesheet.ts, this function is a Singleton, which checks if the window object contains a Stylesheet instance and if not it creates one.

The problem is, that spofiles_mini.js is loaded before the SPFX Webpart/Extension and it puts an "old" Stylesheet object into the global window. When the SPFX webpart is loaded, the Stylesheet instance loads the old object from the window (because its a Singleton).

The old Stylesheet object is missing the "onReset" function, hence the error. You can compare the spofiles-mini.js Stylesheet object (line 4005 or search for = "__stylesheet__") with the current Stylesheet.ts version to see the difference and the missing function.

SvenLauterbach avatar Jun 16 '18 22:06 SvenLauterbach

I am experiencing the issue with "office-ui-fabric-react": "^6.9.0".

dmitrydyachenko avatar Jun 18 '18 10:06 dmitrydyachenko

Hi all, @srideshpande has investigated and is exploring a long-term solution for the issue encountered. His recommendation for the time being is to use the same version of office-ui-fabric-react that SPFX is using, which is 5.112.0 as a workaround (alternatively, anything before 6.8.0 might work as well).

cliffkoh avatar Jun 19 '18 02:06 cliffkoh

This is fixed in #5253.

cliffkoh avatar Jun 19 '18 06:06 cliffkoh

Will be published tonight, sorry for the friction.

dzearing avatar Jun 19 '18 06:06 dzearing

The fix is now published in 6.16.0 and dependencies. Again apologies for the nullref, we've addressed the check and we're looking at a more comprehensive solution to avoid it in the future.

The issue is that there are 2 copies of the same library (merge-styles) on the page. The library has some singleton state. Because there are fighting versions of the library on the same page, the state changes shape depending on the load order. So if old registers first, then new code which (via npm dependencies) expects new merge-styles, it is in for a bad surprise.

In general singletons are evil, but sometimes needed. We're looking at how to mitigate the "2 copies of same library" more thoroughly (either through reduced usage of singletons, or different conventions that make it far less likely for this scenario to occur. Or at the SPFX layer, perhaps we can de-dupe dependencies, which is ideal not just for eliminating these unpredictable scenarios but improving performance as well.)

dzearing avatar Jun 19 '18 15:06 dzearing

After upgrade from 5.131.0 to 6.16.0 it throws below error

[01:56:17] Error - [tsc] node_modules/@uifabric/merge-styles/lib/IStyleSet.d.ts(15,67): error TS1005: ';' expected. [01:56:17] Error - [tsc] node_modules/@uifabric/merge-styles/lib/IStyleSet.d.ts(15,114): error TS1005: '(' expected. [01:56:17] Error - [tsc] node_modules/@uifabric/merge-styles/lib/IStyleSet.d.ts(15,136): error TS1005: '(' expected. [01:56:17] Error - 'tsc' sub task errored after 14 s exited with code 2

jenkinsns avatar Dec 19 '18 02:12 jenkinsns

Fabric 6 has a requirement on TypeScript 2.8. Is there a SPFx release that supports TypeScript 2.8 yet?

You can otherwise try to pin @uifabric/merge-styles to the minbar specified in the 6.16.0 package.json, which is 6.2.0 per https://unpkg.com/[email protected]/package.json, and that should unblock you.

cliffkoh avatar Dec 19 '18 08:12 cliffkoh