@material-ui/core#RootRef JavaScript Examples

The following examples show how to use @material-ui/core#RootRef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckoutItem.jsx    From resilience-app with GNU General Public License v3.0 5 votes vote down vote up
export default function CheckoutItem({ cost, description, name, onChange, quantity }) {
  const classes = useStyles();
  const [open, setOpen] = useState(false);

  const [width, setWidth] = useState(0);
  const ref = useCallback((node) => node && setWidth(node.offsetWidth), []);

  const crop = width / CHAR_WIDTH;
  const formatedDescription =
    description.length > crop ? description.slice(0, crop) + "..." : description;

  return (
      <Divider />
      <ListItem className={classes.listItem}>
        {onChange ? (
              name: "quantity",
              id: "quantity",
            {[...Array(MAX_ORDER + 1)].map((e, i) => (
              <option value={i} key={i}>
        ) : (
          <Typography className={classes.quantity} variant="h4">
        <RootRef rootRef={ref}>
          <Box onClick={() => setOpen(!open)} flex={1} display="flex" flexDirection="column">
            <Typography variant="h4" color="textPrimary">
            {!open && formatedDescription}
            <Collapse in={open} timeout={0}>
            <Expand open={open} />
        <ListItemText className={classes.cost}>
          <Typography variant={onChange ? "h4" : "body1"} color="textPrimary">