material-ui

how to set a default date for a Material-ui TextField Type=date

£可爱£侵袭症+ 提交于 2021-01-29 19:07:37
问题 I just started working with React and I am trying to use a date picker using the material it looks like this: <TextField name="someDate" label="Some Date" InputLabelProps={{ shrink: true, required: true }} helperText={errors.someDate} FormHelperTextProps={{ hidden: !this.hasError('someDate') }} type="date" error={this.hasError('someDate')} onChange={this.handleSomeDateChange} value={values.someDate} /> Setting: type="date" gives me the date picker but it also overlays the format for the

Converting Material-UI to a class in react

为君一笑 提交于 2021-01-29 19:07:30
问题 I am trying to use the 'Stepper' react material-ui component, but I am having difficulty using it in a class fashion, rather than function as they have in their previews. Here is what I have so far, and it does load but with some problems: The text that appears is 'unknown step' meaning that the function 'getStepContent' does not gets called properly Every time I am hitting the 'next' button, it gives me an error saying: 'Cannot read property 'has' of undefined' seems like almost all of my

Expand one card on click

谁都会走 提交于 2021-01-29 18:13:13
问题 Currently using Material-UI-React for the first time to build out cards that expand, the issue I'm running into is when I click on one card to expand, they all expand.How can I refactor my code to only allow the card that is clicked on to expand not affecting the others? const useStyles = makeStyles(theme => ({ card: { maxWidth: 300 }, media: { height: 0, paddingTop: '56.25%' // 16:9 }, expand: { transform: 'rotate(0deg)', marginLeft: 'auto', transition: theme.transitions.create('transform',

Error when using Custom Icon for Switch Component

Deadly 提交于 2021-01-29 17:57:48
问题 When I try to use the custom icon prop I get this error: index.js:1406 Warning: Failed prop type: Invalid prop icon supplied to ForwardRef(Switch) , expected a ReactNode. I have tried several things and I cannot make it work. Any ideas why it is not working? <Switch checked={formik.values.roleBasedAccess} onChange={handleRoleBasedChange} icon={HexagonSwitch} value="roleBasedAccess" /> And the HexagonSwitch component: import React from 'react'; const HexagonSwitch = () => { return ( <svg width

How to render different component onClick using React material-ui Drawer list?

你离开我真会死。 提交于 2021-01-29 17:32:15
问题 I am working on Dashboard design using React material-ui package. I have an App bar and a Drawer with a List of different items. When I click items in Drawer, I want to render the respective component inside the " main " tag of Drawer. The App.js component is class-based. And I have functional component for all other routes and features. import React, { useState } from "react"; import { makeStyles, useTheme } from '@material-ui/core/styles'; import { Link } from 'react-router-dom' import {

Remove Material UI icon margin

一世执手 提交于 2021-01-29 15:32:26
问题 Does anyone know how to remove the margin from material UI icons!? I want for mobile to remove that margin, which is margin-left: -4px and margin-right: 8px ? Is there anyway to override it with classes? The code below is not working: personIcon: { color: theme.palette.primary.main, fontSize: "27px !important", [theme.breakpoints.down("xs")]: { margin: "0px !important", }, }, In addition I want to override it only for the current component. ;] 回答1: You need to target the startIcon

Passing Mapped Data To A Material-UI Modal

↘锁芯ラ 提交于 2021-01-29 13:48:42
问题 I am trying to pass a list of values to buttons. On Clicking the buttons a modal with the specifically mapped value should appear but in my case only the last value (3) in my array appears in all modals... How should I fix it ? state = { open: false, stationData : [ { id:1, number:'1' }, { id:2, number:'2' }, { id:3, number:'3' } ], }; handleOpen = () => { this.setState({ open: true }); }; handleClose = () => { this.setState({ open: false }); }; render() { const {stationData} = this.state;

Material-Ui theming issue with React components imported from a library

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 13:28:52
问题 I'm facing an issue, and I searched in Google to find answer with no chance. I have created a React / material Ui library, with a lot of components extended from Material UI. This library belongs to a yarn workspace, together with a main app. The library is built with webpack and babel. In the main app, I'm importing these components and try to apply the global theme, created in the main app, using ThemeProvider. It's seems to work as first sight. When the lib component is alone in the page,

Material-UI styles: convert functional component to class component

℡╲_俬逩灬. 提交于 2021-01-29 12:43:53
问题 So I try the following code to convert a functional component to the classical component, it kinda worked, no error but styles are not applied . import { makeStyles } from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles'; const playtheMusic = () => { pauseMusic(); }; const pausetheMusic = () => { pauseMusic(); }; const useStyles = makeStyles(theme => ({ text: { padding: 50 }, paper: { paddingBottom: 50 }, list: { marginBottom: theme.spacing(2) }, subheader: {

Function inside Material UI Tabs not firing

≯℡__Kan透↙ 提交于 2021-01-29 11:29:05
问题 I could not reproduce the problem but I tried to. I have a Material UI element with a child I've added inside it. The icon/child is the X in the corner. The tab/parent is the surrounding box. Two problems: I want to click on the child but the parent covers it entirely and the child is not getting clicked. Even if it is clicked, it's inside the Tab icon field and this seems to disrupt the click anyway. handleIconClick(){ console.log('click') } renderIcon() { return ( <div tabIndex="-1"