简体   繁体   English

尽管在我的控制台中成功编译,为什么我的反应应用程序在导入和使用材料 ui 中的图标后显示空白屏幕?

[英]Why is my react app displaying a blank screen after importing and using an icon from material ui despite compiling successfully in my console?

This is the code and it runs fine up until I added the "Avatar" line.这是代码,它运行良好,直到我添加了“头像”行。 I had to use react icons instead of material UI because it wasn't displaying.我不得不使用反应图标而不是材料 UI,因为它没有显示。 I would also appreciate an alternative package I can install that would allow me to use the Avatar component.我也很感激我可以安装一个替代 package,它可以让我使用 Avatar 组件。 Thanks in advance.提前致谢。

import React from 'react';
import { MdOutlineMenu } from 'react-icons/md';
import { FiSearch } from 'react-icons/fi';
import { MdVideoCall } from 'react-icons/md';
import { GrApps } from 'react-icons/gr';
import { IoIosNotifications } from 'react-icons/io';
import Avatar from '@material-ui/core/Avatar';

function header() {
  return (
    <div className='header'>
        <h1>I am a header</h1>
        <MdOutlineMenu />
        <img className='header__logo' 
        src="https://imgs.search.brave.com/0Adz0eT0KyLAofHJ_wU_1- 
        GqmHa0rnORMw9GWm__p0Q/rs:fit:844:225:1/g:ce/aHR0cHM6Ly90c2U0
        /Lm1tLmJpbmcubmV0/L3RoP2lkPU9JUC5f/SWZFYVVzc2paUXda/MXU5MmIxX0dnSGFF
        /SyZwaWQ9QXBp" alt="" />
        <input type="text" />
        <FiSearch />
        <MdVideoCall />
        <GrApps />
        <IoIosNotifications />
        <Avatar alt="Remy Sharp" src="https://avatars2.githubusercontent.com/u/24712956? 
        s=400&u=b71527e605ae1b748fc2d4157a842e57e427ad44&v=4"/>

    </div>
  );
}

export default header; 

As an alternative to material-ui, you can simply use react-avatar.It can be easily be installed into your app using NPM.作为 material-ui 的替代品,您可以简单地使用 react-avatar。它可以使用 NPM 轻松安装到您的应用程序中。 Find the instructions in this article here - https://www.npmjs.com/package/react-avatar .在此处找到本文中的说明 - https://www.npmjs.com/package/react-avatar

I still can't figure out why material-ui is giving me a blank screen.我仍然无法弄清楚为什么 material-ui 给了我一个空白屏幕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 材料 - 用户界面:为什么我的对话框不显示? - Material - UI : Why is my Dialog not displaying? 创建我的第一个反应应用程序并且我的 fontawesome 图标没有显示或加载? - creating my first react app and my fontawesome icon is not displaying or loading? 成功路由到组件后,为什么我的组件的html无法显示? - Why is the html of my components not displaying after successfully routing to it? 使用Jest和react-test-renderer使用Material-UI时,为什么我的渲染器失败? - Why is my renderer failing when using Material-UI using Jest and react-test-renderer? 如何在我的 TreeItem Material UI 4 中添加图标 - How add a icon in my TreeItem Material UI 4 为什么在我的反应应用程序中使用 fetch 发出的调用在邮递员中成功执行时会失败? - Why post call made using fetch in my react app fails when the same is successfully executed in postman? 我的反应组件没有显示,尽管没有错误 - My react component is not displaying despite having no errors 在材料ui中导入svg图标 - importing an svg icon in material ui 为什么我的 React 应用程序中的 console.logs 和 UI 没有显示相同的状态变量? - Why do the console.logs and UI in my React app not show the same state variable? 如何从 Material UI 为我的应用中的 React 添加带有 Back to Top 按钮的 AppBar? - How do I add AppBar with Back to Top button from Material UI for React in my App?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM