Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm a beginner in the new Javascript world and would like to know the difference between

import { MessageBar } from "office-ui-fabric-react";

import { MessageBar } from "office-ui-fabric-react/lib-commonjs/MessageBar";

Both of them seem to work fine. I'm using webpack for creating final JS files. What is the recommended way to import components?

question from:https://stackoverflow.com/questions/65950049/fluent-ui-best-way-to-import-components

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

Both should work. The first one allows you to aggregate all your imports in a single expression.

Note that UI Fabric is deprecated and you should switch to Fluent UI React or Fluent UI React Northstar. So for example your import could look like this:

import { DatePicker, MessageBar } from '@fluentui/react';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...