SlideShare a Scribd company logo
1 of 6
Download to read offline
React mui(): question
I am passing a data into a Item. Everything works correctly except when I try to use <Link to={'/'}
/>. This cause a web package error. When I remove the link it works fine. Also / is a route. I also
tried an wrap link around MenuItem but get an link issue. I copy and paste both method errors
below.
method 1:
method 2(i tried):
My app code(dashboard is wrapped in browser):
without link:
With link:
full- error:
Uncaught TypeError: react__WEBPACK_IMPORTED_MODULE_0__.useContext(...) is null
LinkWithRef index.tsx:424
React 11
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
index.tsx:424
LinkWithRef index.tsx:424
React 11
performConcurrentWorkOnRoot self-hosted:1409
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
(Async: EventHandlerNonNull)
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
Uncaught TypeError: react__WEBPACK_IMPORTED_MODULE_0__.useContext(...) is null
LinkWithRef index.tsx:424
React 12
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
index.tsx:424
LinkWithRef index.tsx:424
React 12
performConcurrentWorkOnRoot self-hosted:1409
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
(Async: EventHandlerNonNull)
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
The above error occurred in the <Link> component:
LinkWithRef@http://localhost:3000/static/js/bundle.js:54228:9 span div li
MenuItem@http://localhost:3000/static/js/bundle.js:50333:18
Item@http://localhost:3000/static/js/bundle.js:344:7 div
./node_modules/@emotion/react/dist/emotion-element-
6a883da9.browser.esm.js/withEmotionCache/<@http://localhost:3000/static/js/bundle.js:1778:66
Box@http://localhost:3000/static/js/bundle.js:9159:72 ul nav
Menu@http://localhost:3000/static/js/bundle.js:50309:18 div div div
ProSidebar@http://localhost:3000/static/js/bundle.js:50200:18 div
./node_modules/@emotion/react/dist/emotion-element-
6a883da9.browser.esm.js/withEmotionCache/<@http://localhost:3000/static/js/bundle.js:1778:66
Box@http://localhost:3000/static/js/bundle.js:9159:72
Sidebar@http://localhost:3000/static/js/bundle.js:379:74 div
InnerThemeProvider@http://localhost:3000/static/js/bundle.js:8374:70
ThemeProvider@http://localhost:3000/static/js/bundle.js:8081:7
ThemeProvider@http://localhost:3000/static/js/bundle.js:8395:7
App@http://localhost:3000/static/js/bundle.js:41:77 Consider adding an error boundary to your tree
to customize error handling behavior. Visit https://reactjs.org/link/error-boundaries to learn more
about error boundaries. react-dom.development.js:18687
React 12
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
(Async: EventHandlerNonNull)
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
Uncaught TypeError: react__WEBPACK_IMPORTED_MODULE_0__.useContext(...) is null
LinkWithRef index.tsx:424
React 9
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
index.tsx:424
LinkWithRef index.tsx:424
React 9
performConcurrentWorkOnRoot self-hosted:1409
workLoop scheduler.development.js:266
flushWork scheduler.development.js:239
performWorkUntilDeadline scheduler.development.js:533
(Async: EventHandlerNonNull)
js scheduler.development.js:571
js scheduler.development.js:633
factory react refresh:6
Webpack 24
method 2 error:
import { Box, IconButton, Typography, useTheme } from "@mui/material";
import React from 'react';
import { useState } from 'react';
import{ ProSidebar, Menu, MenuItem} from 'react-pro-sidebar';
import "react-pro-sidebar/dist/css/styles.css";
import { Link } from "react-router-dom";
import { tokens } from '../../theme';
import HomeOutlinedIcon from '@mui/icons-material/HomeOutlined';
import PeopleAltOutlinedIcon from '@mui/icons-material/PeopleAltOutlined';
import ReceiptLongOutlinedIcon from '@mui/icons-material/ReceiptLongOutlined';
import CalendarMonthOutlinedIcon from '@mui/icons-material/CalendarMonthOutlined';
import HelpOutlineOutlinedIcon from '@mui/icons-material/HelpOutlineOutlined';
import BarChartOutlinedIcon from '@mui/icons-material/BarChartOutlined';
import PieChartOutlineOutlinedIcon from '@mui/icons-material/PieChartOutlineOutlined';
import ViewTimelineOutlinedIcon from '@mui/icons-material/ViewTimelineOutlined';
import MenuOutlinedIcon from '@mui/icons-material/MenuOutlined';
import MapOutlinedIcon from '@mui/icons-material/MapOutlined';
import LightModeOutlined from "@mui/icons-material/LightModeOutlined";
import ContactPageOutlinedIcon from '@mui/icons-material/ContactPageOutlined';
// Item component
const Item = ( { title , to, icon, selected , setSelected}) =>{
const theme = useTheme();
const colors = tokens(theme.palette.mode);
return(
<MenuItem
active={selected === title}
style={{
color: colors.grey[100],
}}
onClick={() => setSelected(title)}
icon={icon}
>
<Typography>{title}</Typography>
</MenuItem>
)
}
function Sidebar() {
const theme = useTheme();
const colors = tokens(theme.palette.mode);
const [isClosed, setIsClosed] = useState(false);
const [selected, setSelected] = useState("Dashboard")
return (
<Box
sx={{
"& .pro-sidebar-inner": {
background: `${colors.primary[400]} !important`,
},
"& .pro-icon-wrapper": {
backgroundColor: "transparent !important",
},
"& .pro-inner-item": {
padding: "5px 35px 5px 20px !important",
},
"& .pro-inner-item:hover": {
color: "#868dfb !important",
},
"& .pro-menu-item.active": {
color: "#6870fa !important",
},
}}
>
<ProSidebar collapsed = {isClosed}>
<Menu iconShape="square">
<MenuItem
onClick={() => setIsClosed(!isClosed)}
icon={isClosed ? <MenuOutlinedIcon /> : undefined}
style={{
margin: "10px 0 20px 0",
color: colors.grey[100],
}}
>
{!isClosed && (
<Box
display="flex"
justifyContent="space-between"
alignItems="center"
ml="15px"
>
<Typography variant="h3" color={colors.grey[100]}>
Admin
</Typography>
<IconButton onClick={() => setIsClosed(!isClosed)}>
<MenuOutlinedIcon />
</IconButton>
</Box>
)}
</MenuItem>
{!isClosed && (
<Box mb="25px">
{/* {user profile } */}
<Box display="flex" justifyContent="center" alignItems="center">
<img
alt="profile-user"
width="100px"
height="100px"
src={`../../images/user.png`}
style={{ cursor: "pointer", borderRadius: "50%", border:"solid", color: "lightgray"}}
/>
</Box>
<Box textAlign="center">
<Typography
variant="h2"
color={colors.grey[100]}
fontWeight="bold"
sx={{ m: "10px 0 0 0" }}
>
Sleeping cat
</Typography>
<Typography variant="h5" color={colors.greenAccent[500]}>
SC Admin
</Typography>
</Box>
</Box>
)}
{/*Menu options */}
{/*Menu options */}
<Box paddingLeft={isClosed ? undefined : "10%"}>
<Item
title="Dashboard"
to="/"
icon={<HomeOutlinedIcon />}
selected={selected}
setSelected={setSelected}
/>
</Box>
</Menu>
</ProSidebar>
</Box>
)
}
export default Sidebar
import React from 'react'; import { ColorModeContext, useMode } from './theme'; import {
Cssbaseline, ThemeProvider } from 'Omui/material'; import {Routes, Route, BrowserRouter } from
"react-router-dom" import Topbar from './sections/global/Topbar'; import Dashboard from
'./pages/dashboard'; import Sidebar from './sections/global/Sidebar'; ) } export default App;

More Related Content

Similar to React mui question I am passing a data into a Item Every.pdf

HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
Evan Schultz
 

Similar to React mui question I am passing a data into a Item Every.pdf (20)

Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
Паразитируем на React-экосистеме (Angular 4+) / Алексей Охрименко (IPONWEB)
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next Framework
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
 
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
 
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web Services
 
Vue js and Dyploma
Vue js and DyplomaVue js and Dyploma
Vue js and Dyploma
 
iOS Contact List Application Tutorial
iOS Contact List Application TutorialiOS Contact List Application Tutorial
iOS Contact List Application Tutorial
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
Building an angular application -1 ( API: Golang, Database: Postgres) v1.0
 
Vue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexVue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and Vuex
 
Angular 2 binding
Angular 2  bindingAngular 2  binding
Angular 2 binding
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
Introducing Vuex in your project
Introducing Vuex in your projectIntroducing Vuex in your project
Introducing Vuex in your project
 
State manager in Vue.js, from zero to Vuex
State manager in Vue.js, from zero to VuexState manager in Vue.js, from zero to Vuex
State manager in Vue.js, from zero to Vuex
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
 

More from accostinternational

C Jones is a 63yearold female with a fiveyear history of.pdf
C Jones is a 63yearold female with a fiveyear history of.pdfC Jones is a 63yearold female with a fiveyear history of.pdf
C Jones is a 63yearold female with a fiveyear history of.pdf
accostinternational
 
The following assumptions and exhibits will be used in prepa.pdf
The following assumptions and exhibits will be used in prepa.pdfThe following assumptions and exhibits will be used in prepa.pdf
The following assumptions and exhibits will be used in prepa.pdf
accostinternational
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
accostinternational
 
please and thank you Adapted from Kristen St John James.pdf
please and thank you  Adapted from Kristen St John James.pdfplease and thank you  Adapted from Kristen St John James.pdf
please and thank you Adapted from Kristen St John James.pdf
accostinternational
 
K Direktr olarak David bir eitlilik ynetimi program pla.pdf
K Direktr olarak David bir eitlilik ynetimi program pla.pdfK Direktr olarak David bir eitlilik ynetimi program pla.pdf
K Direktr olarak David bir eitlilik ynetimi program pla.pdf
accostinternational
 

More from accostinternational (20)

6 In humans the Rh blood group has only two alleles R and.pdf
6 In humans the Rh blood group has only two alleles R and.pdf6 In humans the Rh blood group has only two alleles R and.pdf
6 In humans the Rh blood group has only two alleles R and.pdf
 
Cual de los siguientes es verdadero El uso tico de las c.pdf
Cual de los siguientes es verdadero  El uso tico de las c.pdfCual de los siguientes es verdadero  El uso tico de las c.pdf
Cual de los siguientes es verdadero El uso tico de las c.pdf
 
Consider the transaction database represented by the matrix .pdf
Consider the transaction database represented by the matrix .pdfConsider the transaction database represented by the matrix .pdf
Consider the transaction database represented by the matrix .pdf
 
Complete the following table SourceAnnual Dose .pdf
Complete the following table    SourceAnnual Dose .pdfComplete the following table    SourceAnnual Dose .pdf
Complete the following table SourceAnnual Dose .pdf
 
Professional Development Initiative Scenario As current o.pdf
Professional Development Initiative Scenario   As current o.pdfProfessional Development Initiative Scenario   As current o.pdf
Professional Development Initiative Scenario As current o.pdf
 
Write python code to do the following Define a class call.pdf
Write python code to do the following  Define a class call.pdfWrite python code to do the following  Define a class call.pdf
Write python code to do the following Define a class call.pdf
 
When attempting to determine the identity of a person who re.pdf
When attempting to determine the identity of a person who re.pdfWhen attempting to determine the identity of a person who re.pdf
When attempting to determine the identity of a person who re.pdf
 
What are your 2 favorite ways to communicate with someone pe.pdf
What are your 2 favorite ways to communicate with someone pe.pdfWhat are your 2 favorite ways to communicate with someone pe.pdf
What are your 2 favorite ways to communicate with someone pe.pdf
 
C Jones is a 63yearold female with a fiveyear history of.pdf
C Jones is a 63yearold female with a fiveyear history of.pdfC Jones is a 63yearold female with a fiveyear history of.pdf
C Jones is a 63yearold female with a fiveyear history of.pdf
 
We know the following expected returns for stocks A and B g.pdf
We know the following expected returns for stocks A and B g.pdfWe know the following expected returns for stocks A and B g.pdf
We know the following expected returns for stocks A and B g.pdf
 
The following assumptions and exhibits will be used in prepa.pdf
The following assumptions and exhibits will be used in prepa.pdfThe following assumptions and exhibits will be used in prepa.pdf
The following assumptions and exhibits will be used in prepa.pdf
 
Task 4 The scope of variables What is the output of the fol.pdf
Task 4 The scope of variables What is the output of the fol.pdfTask 4 The scope of variables What is the output of the fol.pdf
Task 4 The scope of variables What is the output of the fol.pdf
 
A Describir cmo se transporta la informacin gentica en l.pdf
A Describir cmo se transporta la informacin gentica en l.pdfA Describir cmo se transporta la informacin gentica en l.pdf
A Describir cmo se transporta la informacin gentica en l.pdf
 
EXHIBIT 515 Payroll System FlowchartFollowing is a selec.pdf
EXHIBIT 515 Payroll System FlowchartFollowing is a selec.pdfEXHIBIT 515 Payroll System FlowchartFollowing is a selec.pdf
EXHIBIT 515 Payroll System FlowchartFollowing is a selec.pdf
 
Regarding the ENS The descending interneurons release 1 t.pdf
Regarding the ENS The descending interneurons release 1 t.pdfRegarding the ENS The descending interneurons release 1 t.pdf
Regarding the ENS The descending interneurons release 1 t.pdf
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
 
please and thank you Adapted from Kristen St John James.pdf
please and thank you  Adapted from Kristen St John James.pdfplease and thank you  Adapted from Kristen St John James.pdf
please and thank you Adapted from Kristen St John James.pdf
 
Joe and Jessie are married and have one dependent child Liz.pdf
Joe and Jessie are married and have one dependent child Liz.pdfJoe and Jessie are married and have one dependent child Liz.pdf
Joe and Jessie are married and have one dependent child Liz.pdf
 
K Direktr olarak David bir eitlilik ynetimi program pla.pdf
K Direktr olarak David bir eitlilik ynetimi program pla.pdfK Direktr olarak David bir eitlilik ynetimi program pla.pdf
K Direktr olarak David bir eitlilik ynetimi program pla.pdf
 
khikdhficdadfbfcabcg Change all expression into c.pdf
khikdhficdadfbfcabcg  Change all expression into c.pdfkhikdhficdadfbfcabcg  Change all expression into c.pdf
khikdhficdadfbfcabcg Change all expression into c.pdf
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 

React mui question I am passing a data into a Item Every.pdf

  • 1. React mui(): question I am passing a data into a Item. Everything works correctly except when I try to use <Link to={'/'} />. This cause a web package error. When I remove the link it works fine. Also / is a route. I also tried an wrap link around MenuItem but get an link issue. I copy and paste both method errors below. method 1: method 2(i tried): My app code(dashboard is wrapped in browser): without link: With link: full- error: Uncaught TypeError: react__WEBPACK_IMPORTED_MODULE_0__.useContext(...) is null LinkWithRef index.tsx:424 React 11 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 index.tsx:424 LinkWithRef index.tsx:424 React 11 performConcurrentWorkOnRoot self-hosted:1409 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 (Async: EventHandlerNonNull) js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 Uncaught TypeError: react__WEBPACK_IMPORTED_MODULE_0__.useContext(...) is null LinkWithRef index.tsx:424 React 12 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6
  • 2. Webpack 24 index.tsx:424 LinkWithRef index.tsx:424 React 12 performConcurrentWorkOnRoot self-hosted:1409 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 (Async: EventHandlerNonNull) js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 The above error occurred in the <Link> component: LinkWithRef@http://localhost:3000/static/js/bundle.js:54228:9 span div li MenuItem@http://localhost:3000/static/js/bundle.js:50333:18 Item@http://localhost:3000/static/js/bundle.js:344:7 div ./node_modules/@emotion/react/dist/emotion-element- 6a883da9.browser.esm.js/withEmotionCache/<@http://localhost:3000/static/js/bundle.js:1778:66 Box@http://localhost:3000/static/js/bundle.js:9159:72 ul nav Menu@http://localhost:3000/static/js/bundle.js:50309:18 div div div ProSidebar@http://localhost:3000/static/js/bundle.js:50200:18 div ./node_modules/@emotion/react/dist/emotion-element- 6a883da9.browser.esm.js/withEmotionCache/<@http://localhost:3000/static/js/bundle.js:1778:66 Box@http://localhost:3000/static/js/bundle.js:9159:72 Sidebar@http://localhost:3000/static/js/bundle.js:379:74 div InnerThemeProvider@http://localhost:3000/static/js/bundle.js:8374:70 ThemeProvider@http://localhost:3000/static/js/bundle.js:8081:7 ThemeProvider@http://localhost:3000/static/js/bundle.js:8395:7 App@http://localhost:3000/static/js/bundle.js:41:77 Consider adding an error boundary to your tree to customize error handling behavior. Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries. react-dom.development.js:18687 React 12 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 (Async: EventHandlerNonNull) js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 Uncaught TypeError: react__WEBPACK_IMPORTED_MODULE_0__.useContext(...) is null
  • 3. LinkWithRef index.tsx:424 React 9 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 index.tsx:424 LinkWithRef index.tsx:424 React 9 performConcurrentWorkOnRoot self-hosted:1409 workLoop scheduler.development.js:266 flushWork scheduler.development.js:239 performWorkUntilDeadline scheduler.development.js:533 (Async: EventHandlerNonNull) js scheduler.development.js:571 js scheduler.development.js:633 factory react refresh:6 Webpack 24 method 2 error: import { Box, IconButton, Typography, useTheme } from "@mui/material"; import React from 'react'; import { useState } from 'react'; import{ ProSidebar, Menu, MenuItem} from 'react-pro-sidebar'; import "react-pro-sidebar/dist/css/styles.css"; import { Link } from "react-router-dom"; import { tokens } from '../../theme'; import HomeOutlinedIcon from '@mui/icons-material/HomeOutlined'; import PeopleAltOutlinedIcon from '@mui/icons-material/PeopleAltOutlined'; import ReceiptLongOutlinedIcon from '@mui/icons-material/ReceiptLongOutlined'; import CalendarMonthOutlinedIcon from '@mui/icons-material/CalendarMonthOutlined'; import HelpOutlineOutlinedIcon from '@mui/icons-material/HelpOutlineOutlined'; import BarChartOutlinedIcon from '@mui/icons-material/BarChartOutlined'; import PieChartOutlineOutlinedIcon from '@mui/icons-material/PieChartOutlineOutlined'; import ViewTimelineOutlinedIcon from '@mui/icons-material/ViewTimelineOutlined'; import MenuOutlinedIcon from '@mui/icons-material/MenuOutlined'; import MapOutlinedIcon from '@mui/icons-material/MapOutlined'; import LightModeOutlined from "@mui/icons-material/LightModeOutlined"; import ContactPageOutlinedIcon from '@mui/icons-material/ContactPageOutlined'; // Item component
  • 4. const Item = ( { title , to, icon, selected , setSelected}) =>{ const theme = useTheme(); const colors = tokens(theme.palette.mode); return( <MenuItem active={selected === title} style={{ color: colors.grey[100], }} onClick={() => setSelected(title)} icon={icon} > <Typography>{title}</Typography> </MenuItem> ) } function Sidebar() { const theme = useTheme(); const colors = tokens(theme.palette.mode); const [isClosed, setIsClosed] = useState(false); const [selected, setSelected] = useState("Dashboard") return ( <Box sx={{ "& .pro-sidebar-inner": { background: `${colors.primary[400]} !important`, }, "& .pro-icon-wrapper": { backgroundColor: "transparent !important", }, "& .pro-inner-item": { padding: "5px 35px 5px 20px !important", }, "& .pro-inner-item:hover": { color: "#868dfb !important", }, "& .pro-menu-item.active": { color: "#6870fa !important", }, }} > <ProSidebar collapsed = {isClosed}>
  • 5. <Menu iconShape="square"> <MenuItem onClick={() => setIsClosed(!isClosed)} icon={isClosed ? <MenuOutlinedIcon /> : undefined} style={{ margin: "10px 0 20px 0", color: colors.grey[100], }} > {!isClosed && ( <Box display="flex" justifyContent="space-between" alignItems="center" ml="15px" > <Typography variant="h3" color={colors.grey[100]}> Admin </Typography> <IconButton onClick={() => setIsClosed(!isClosed)}> <MenuOutlinedIcon /> </IconButton> </Box> )} </MenuItem> {!isClosed && ( <Box mb="25px"> {/* {user profile } */} <Box display="flex" justifyContent="center" alignItems="center"> <img alt="profile-user" width="100px" height="100px" src={`../../images/user.png`} style={{ cursor: "pointer", borderRadius: "50%", border:"solid", color: "lightgray"}} /> </Box> <Box textAlign="center"> <Typography variant="h2" color={colors.grey[100]} fontWeight="bold"
  • 6. sx={{ m: "10px 0 0 0" }} > Sleeping cat </Typography> <Typography variant="h5" color={colors.greenAccent[500]}> SC Admin </Typography> </Box> </Box> )} {/*Menu options */} {/*Menu options */} <Box paddingLeft={isClosed ? undefined : "10%"}> <Item title="Dashboard" to="/" icon={<HomeOutlinedIcon />} selected={selected} setSelected={setSelected} /> </Box> </Menu> </ProSidebar> </Box> ) } export default Sidebar import React from 'react'; import { ColorModeContext, useMode } from './theme'; import { Cssbaseline, ThemeProvider } from 'Omui/material'; import {Routes, Route, BrowserRouter } from "react-router-dom" import Topbar from './sections/global/Topbar'; import Dashboard from './pages/dashboard'; import Sidebar from './sections/global/Sidebar'; ) } export default App;