DEV Community

Cover image for React js & material UI
Dezina
Dezina

Posted on

3 2

React js & material UI

1. Link

**Parent component**
import { Link } from 'react-router-dom'

<Link
                              to={{
                                pathname: "/dashboard/selectmapsubjctefaculaty",
                                state: { row }
                              }}
                            >
                              <Button
                                size='small'
                                className='mr-1 fullWidth'
                                color="secondary"
                                variant='contained'
                                sx={{ width: "100%", p: "0.1em", borderRadius: "2px" }}
                              >Assign Faculty</Button></Link>

**Child component**

import { useLocation } from 'react-router-dom/cjs/react-router-dom.min'

 const location = useLocation()

  let subject = location.state.row

Enter fullscreen mode Exit fullscreen mode

2. MUI Autocomplete

import { Autocomplete, Box, TextField } from '@mui/material'
import React, { Fragment, useState } from 'react'
import styled from '@emotion/styled';

 const _handleInputChange = (e, data) => {
    if (e.target.value.length > 3) {
      GET_SEARCH_STUDENT(e.target.value)
    }
  }
  const _handleChnage = async (e, value) => {
    let res = await GET_STUDENT_DETAILS(value?.id)
    setStudentDetails(res)
  }
  const _handleAddFee = () => {
    setAddFeeType(!AddFeeType)
  }

  <Autocomplete
        sx={{ boxShadow: 4 }}
        id="auto-com"
        options={searchStudent}
        renderInput={params => (
          <StyledInputBase {...params} label="Search student" />
        )}
        getOptionLabel={option => `${option?.firstname} ${option?.lastname} ${option?.phone}`}
        style={{ boxShadow: 3 }}
        onChange={(e, newvalue) => {
          _handleChnage(e, newvalue)
        }}
        onInputChange={handleInputChange}
      />


Enter fullscreen mode Exit fullscreen mode

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay