2

I created Context Menu button in Document library (not web part) that displays some info using 'office-ui-fabric-react' library.

The problem is when I open my SharePoint Online page and my extension loads, I get millions of console warnings.

I tried to disable it that way:

import { setIconOptions } from 'office-ui-fabric-react/lib/Styling';
setIconOptions({
  disableWarnings: true
});

It doesn't help. And I need only three icons.

What can I do in this situation?

Thank you!

Analytick
  • 21
  • 1
  • 3

1 Answers1

2

If your code is running in an environment where icons may have already been registered, you may need to disable the warnings.

To initialize icons and avoid duplication warnings, pass options into initializeIcons:

import { initializeIcons } from '@uifabric/icons';

initializeIcons(undefined, { disableWarnings: true });
Sreeraj Sree
  • 177
  • 10
  • I get error: Expected 0-1 arguments, but got 2. (alias) initializeIcons(baseUrl?: string): void import initializeIcons – Analytick Jun 13 '18 at 15:16
  • 1
    import { setWarningCallback } from 'office-ui-fabric-react/lib/Utilities'; setWarningCallback(() => undefined); Please try the above code as well – Sreeraj Sree Jun 13 '18 at 15:36
  • Where to use that snippet? I tried to use it in Webpart.tsx but it doesn't suppresses the warning. – ateet Nov 23 '18 at 11:18