What is the muiName property and when do I have to set it for Material-UI components?

后端 未结 2 1166
忘掉有多难
忘掉有多难 2021-01-28 12:18

In the offical material-ui documentation an example for the AppBar component here looks like this:

import React, {Component} from \'react\';
import A         


        
2条回答
  •  我在风中等你
    2021-01-28 12:52

    Answer in documentation is:

    In order to provide the maximum flexibility and performance, we need a way to know the nature of the child elements a component receives. To solve this problem we tag some of our components when needed with a muiName static property.

    Let's check this example: // @flow weak

    import React from 'react';
    import IconButton from 'material-ui/IconButton';
    import Icon from 'material-ui/Icon';
    
    const WrappedIcon = props => ;
    WrappedIcon.muiName = 'Icon';
    
    export default function Composition() {
      return (
        
    alarm alarm
    ); }

    If you wrapped material-ui component you should set 'muiName' property to wrapper component with value as name of material-ui component you wrapped. I hope you understand this phrase :)

提交回复
热议问题