React js & material UI
Dezina
Posted on June 30, 2022
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
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}
/>
💖 💪 🙅 🚩
Dezina
Posted on June 30, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
privacy Caught in the Crunch My Journey from Snacks to 2 Million Exposed Users Privacy
November 30, 2024
devchallenge Submission for the DevCycle Feature Flag Challenge: Feature Flag Funhouse
November 30, 2024