score:3
Accepted answer
i would do smt like this. react is really functional:
import react from "react";
import select from "@material-ui/core/select";
export default function app() {
const getdisabled = val => {
if (val) return { disabled: true };
return {};
};
return (
<div classname="app">
<select
// you can pass under the readonly prop
{...getdisabled(true)}
// other props here
/>
</div>
);
}
so, with your example:
export class rowselectcomponent extends react.component {
getdisabled = val => {
if (val) return { disabled: true };
return {};
}
render() {
const {details, classes, name, displayname, values, updatescenariodetailsfield, readonly=false} = this.props;
return <formrow>
<formlabel>{displayname}</formlabel>
<formcontent>
<select
value={details && details[name]}
onchange={(event) => {
updatescenariodetailsfield(name, event.target.value);
}}
{...this.getdisabled(readonly)}
classname={classes.input}
>
{values && values.map((value, index) =>
<menuitem key={index} value={value}>{value}</menuitem>
)}
</select></formcontent>
</formrow>;
}
}
Source: stackoverflow.com
Related Query
- Material UI - how to disable select on condition
- How to disable underline to Material UI's datepicker in React?
- How can I add an icon to Material UI Select options?
- How to test Material UI Select Component with React Testing Library
- How to disable ripple in Material Design React
- How to change material UI select border and label
- How to avoid Material UI Select focus when option is chosen?
- How to disable the selection of an item when the first letter of the option is pressed in the Select component?
- How to disable IconButton ripple effect in Material UI?
- How to change text, icon and underline color of Select in Material UI
- How to disable past dates from today date with Material ui reactjs?
- How to set the width of material ui Popper to its container's width while setting disable portal as false
- How to disable the Material UI Link API component
- How to align several different Material UI select components?
- How can I style a Select from Material UI with styled components?
- How to Disable the ENTER Key in React Material UI Autocomplete form
- How to trigger Material UI Select in Cypress
- Antd select element: how can I disable typing?
- How to Disable today's date using date pickers - material ui
- How to detect if React Material UI Select Field is expanded?
- How to change the material ui popover height which gets open on select
- How to disable some specific columns from edit in react material table?
- Material UI: How can I change the border color of the Select component?
- how to set button disable in certain condition in react?
- How to have multi line options in a select Material UI
- Material UI Multiple Select | How to use Multiple Select with arrays
- how to display a value other than the renderValue in material ui select
- How can I access the custom target attribute within material UI select options in React js
- How to disable ripple effect on Material UI Input?
- How customize material ui select
More Query from same tag
- How to dynamically import react module which is json data
- How do I use Redux state in a useEffect function
- Lazy load components in react
- Page source not showing data fetched from api in next.js
- Nextjs active navigation bar with styled-components
- Typescript Redux Thunk (Types)
- React Show data with page refresh on Button click
- How to wrap too long title in DropdownButton from react-bootstrap?
- How do I Display Images in React which are downloaded as Files & saved in a Folder on the Server with the Filepath stored in my Database?
- How to render object data to table with Reactjs
- axios post request as query to neo4j graph DB
- Firebase Firestore emulator error `Host has been set in both settings() and useEmulator(), emulator host will be used`
- Which way should I import React?
- Antd V3. Table component. How to calculate sum of column values
- How to use webpack with create-react-app?
- Each child in a list should have a unique "key" warning when every key is already unique
- How to distinguish if useEffect is triggered by route change
- How to remove # at link localhost in react js
- WebPack-React-TypeScript: loading CSS and exporting types
- Child prop value not updated on Window , but i can see it get updated in console
- Catching parameters in redirect with Gatsby.js
- How pass parameter in pug?
- Gatsby and Netlify CMS Image Widget: Is it possible to use an image or a url string?
- Redux nested objects as state - is this possible/optimal
- Firebase Storage - Wait till all upload tasks are completed before executing function
- Mocking TimelineMax and TweenMax modules in Jest
- How to use values from Formik initial values and pass them back into React Select?
- Default props are not available in first time render ReactJS
- Sending Azure token to API back-end keeps returning 401 Unauthorzied error when OnTokenValidated is added to the API
- React Admin: I'd like to route to <Show> view from a list