Web
React 분류

[React] material-ui 추가

작성자 정보

  • codls 작성
  • 작성일

컨텐츠 정보

본문

1. Material-UI 설치

npm install @material-ui/icons @mui/material @material-ui/core @mui/system
 
2. 컴포넌트 분리
images%2Fexoluse%2Fpost%2F1206bfc0-5c88-4856-aed5-aa9dd9dac6c9%2FScreen%20Shot%202021-09-18%20at%2012.53.59%20AM.png
 
1) Header.js (상단)

   
      import { AppBar, IconButton, Toolbar, Typography } from '@material-ui/core';
      import { Menu as MenuIcon } from "@material-ui/icons";
       
      function Header() {
      return (
      <AppBar position="static">
      <Toolbar variant="dense">
      <IconButton edge="start" color="inherit" aria-label="menu" sx={{ mr: 2 }}>
      <MenuIcon />
      </IconButton>
      <Typography variant="h6" color="inherit" component="div">exoluse-react</Typography>
      </Toolbar>
      </AppBar>
      )}
      export default Header;
      
    
   
 
2) Bottomjs (하단)

         import { Restore as RestoreIcon, Favorite as FavoriteIcon, LocationOn as LocationOnIcon } from "@material-ui/icons";
         import { Paper, BottomNavigation, BottomNavigationAction } from '@mui/material';
          
         function Bottom() {
         return (
         <Paper sx={{ position: 'fixed', bottom: 0, left: 0, right: 0 }} elevation={3}>
         <BottomNavigationshowLabelsonChange={(event, newValue) => { // setValue(newValue);}}>
         <BottomNavigationAction label="Recents" icon={<RestoreIcon />} />
         <BottomNavigationAction label="Favorites" icon={<FavoriteIcon />} />
         <BottomNavigationAction label="Nearby" icon={<LocationOnIcon />} />
         </BottomNavigation>
         </Paper>
         )}
         export default Bottom;
         
 
3) EmpList.js (목록)

         import {useEffect, useState} from 'react';import { Link, useHistory } from 'react-router-dom';
         import { Add as AddIcon } from "@material-ui/icons";
         import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper, Fab } from '@mui/material';import './App.css';
          
         function EmpList() {
         let history = useHistory();
         let [empList, changeEmpList] = useState([]);
         let [refreshComponent, changeRefreshComponent] = useState("");
          
         useEffect( ()=>{
         fetch("http://localhost:3001/getEmpList").then((response)=>{
         return response.json();}).then( (response)=>{changeEmpList(response.data);} )}, [ refreshComponent ] );
          
         return (<><TableContainer component={Paper}><Table aria-label="simple table"><TableHead><TableRow><TableCell align="center">Id</TableCell><TableCell align="center">Name</TableCell></TableRow></TableHead><TableBody>{empList.map((row) => (<TableRowkey={row.id}sx={{ '&:last-child td, &:last-child th': { border: 0 } }}><TableCell component="th" scope="row" align="center">{row.id}</TableCell><TableCell align="center"><Link to={ '/detail/'+row.id }>{row.name}</Link></TableCell></TableRow>))}</TableBody></Table></TableContainer><Link to={ '/insert'}><Fab sx={{ position: 'fixed', bottom: 70, right: 10 }} color="primary" aria-label="add"><AddIcon /></Fab></Link></>)}
          
         export default EmpList;
         
 
 
images%2Fexoluse%2Fpost%2Fde54fc08-ec6b-4c79-803f-6f171d4e46f7%2FScreen%20Shot%202021-09-18%20at%2012.50.32%20AM.png
 

관련자료

댓글 0
등록된 댓글이 없습니다.
전체 40 / 1 페이지
RSS
  • 웹개발에 자주 쓰는 자바스크립트 라이브러리들 - 슬라이…
    등록자 tjslli
    등록일 05.08 조회 1711

    Html 슬라이드/갤러리 (Carousel) 01. 가장 유명한 Slick - https://kenwheeler.github.io/slick/ 설치 &l…

  • [CSS]css 가상 선택자 정리 및 비교 (nth-c…
    등록자 CSS러버
    등록일 05.08 조회 1627

    Html :nth-child(N)= 부모안에 모든 요소 중 N번째 요소 A:nth-of-type(N)= 부모안에 A라는 요소 중 N번째 요소 :first…

  • 스크롤 이벤트 감지 + jquery + css
    등록자 webveloper
    등록일 04.15 조회 1740

    Html 1. css .caritem{display:flex;align-items:end;flex-direction:column;background:#0…

  • slick slider 커스텀으로 꾸미기 + jquer…
    등록자 webveloper
    등록일 04.15 조회 1776

    Html 1. import <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.n…

  • 호버(hover) 할 때 jquery 이벤트 감지 방법
    등록자 webveloper
    등록일 04.15 조회 1787

    Html 안녕하세요. html 코딩 시 hover 할때 감지하는 이벤트 스크립트입니다. <style> .con-group { display: …

  • 그누보드 썸네일 이미지 화질 개선 방법
    등록자 PixelProphet
    등록일 01.10 조회 2736

    Php 그누보드에서 이미지를 올릴때, 간혹 이미지 화질이 떨어져 보이는 현상이 있습니다.... 이럴 때 제가 찾아본 방법 중에 가장 쉽게 해결 할 수 …

  • React 유튜브 채널 추천
    등록자 코드워리어
    등록일 01.09 조회 2200

    React React는 웹 개발에서 매우 인기 있는 라이브러리로, 학습을 위해 다양한 자료들이 필요합니다. React를 학습하고 싶은 분들을 위한 유튜버 …

  • PHP 배열의 기초
    등록자 console
    등록일 01.05 조회 2531

    Php 배열(array)이란? PHP에서 배열(array)은 맵(map)으로 이루어진, 순서가 있는 집합을 의미합니다. 맵(map)은한 쌍의 키(key…

  • PHP 기타 제어문
    등록자 console
    등록일 01.05 조회 2565

    Php 루프의 제어 일반적으로 조건식의 검사를 통해 루프로 진입하면,다음 조건식을검사하기 전까지 루프 안에 있는 모든 명령문을 실행합니다. 사용자는 c…

  • PHP 반복문
    등록자 console
    등록일 01.05 조회 2533

    Php 반복문 반복문이란 프로그램 내에서 같은 명령을 일정 횟수만큼 반복하여수행하는명령문입니다. 프로그램이 처리하는 대부분의코드는 반복적인 형태가 많으…

  • PHP 조건문
    등록자 console
    등록일 01.05 조회 2383

    Php PHP 표현식 표현식(expressions)은 PHP에서 가장 중요한 구성요소입니다. 표현식이란 모든 것이 값을 갖는다는 의미이며, PHP에서 …

  • PHP 기타 연산자
    등록자 console
    등록일 01.05 조회 2350

    Php 삼항 연산자(ternaryoperator) 삼항 연산자는 유일하게 피연산자를 세 개나 가지는 조건 연산자입니다. 삼항 연산자의 문법은 다음과 같…

  • PHP 비트 연산자
    등록자 console
    등록일 01.05 조회 2559

    Php 비트 연산자(bitwise operator) 비트 연산자는 논리 연산자와 비슷하지만, 비트(bit) 단위로 논리 연산을 수행합니다. 또한, 비트…

  • PHP 논리 연산자
    등록자 console
    등록일 01.05 조회 2617

    Php 논리 연산자(logical operator) 논리 연산자는 논리식을 판단하여, 참(true)과 거짓(false)을 반환합니다. and, or, …

  • PHP 비교 연산자
    등록자 console
    등록일 01.05 조회 2637

    Php 비교 연산자(comparisonoperator) 비교 연산자는피연산자사이의 상대적인 크기를 판단하여,참(true)과 거짓(false)을 반환합니…