admin管理员组

文章数量:1405366

I tried to assign div side by side in my react website. However,I received the error Uncaught Invariant Violation: Minified React error.

This is my toolbar in my react website

let EnhancedTableToolbar = props => {
  const { numSelected, classes ,deletefunc} = props;

  return (
    <Toolbar
      className={classNames(classes.root, {
        [classes.highlight]: numSelected > 0,
      })}
    >
      <div className={classes.title}>
        {numSelected > 0 ? (
          <Typography color="inherit" variant="subtitle1">
            {numSelected} selected
          </Typography>
        ) : (
          <Typography variant="h6" id="tableTitle">
            User List
          </Typography>
        )}
      </div>
      <div className={classes.spacer} />
      <div className={classes.actions}>
        {numSelected > 0 ? (
        <div>
        <div style="width: 100px; float:right;">
          <Tooltip title="Delete">
            <IconButton aria-label="Delete">
              <DeleteIcon onClick={() => { if (window.confirm('Are you sure you wish to delete '+numSelected +' item?')) {deletefunc()} } }>
              </DeleteIcon>
            </IconButton>
          </Tooltip>
         </div>
         <div style="width: 100px; float:right;">
          <Tooltip title="Edit">
            <IconButton aria-label="Edit">
              <EditIcon>
              </EditIcon>
            </IconButton>
          </Tooltip>
          </div>
         </div> 


        ) : (
          <Tooltip title="Filter list">
            <IconButton aria-label="Filter list">
              <FilterListIcon />
            </IconButton>
          </Tooltip>
        )}


      </div>
    </Toolbar>
  );
};

I received the error when I set the width to 100px and float to right in my delete button and edit button. The code will work if I never set the width and float. However,it div by up down instead of side by side. Anyone know how to solve this issue?

I tried to assign div side by side in my react website. However,I received the error Uncaught Invariant Violation: Minified React error.

This is my toolbar in my react website

let EnhancedTableToolbar = props => {
  const { numSelected, classes ,deletefunc} = props;

  return (
    <Toolbar
      className={classNames(classes.root, {
        [classes.highlight]: numSelected > 0,
      })}
    >
      <div className={classes.title}>
        {numSelected > 0 ? (
          <Typography color="inherit" variant="subtitle1">
            {numSelected} selected
          </Typography>
        ) : (
          <Typography variant="h6" id="tableTitle">
            User List
          </Typography>
        )}
      </div>
      <div className={classes.spacer} />
      <div className={classes.actions}>
        {numSelected > 0 ? (
        <div>
        <div style="width: 100px; float:right;">
          <Tooltip title="Delete">
            <IconButton aria-label="Delete">
              <DeleteIcon onClick={() => { if (window.confirm('Are you sure you wish to delete '+numSelected +' item?')) {deletefunc()} } }>
              </DeleteIcon>
            </IconButton>
          </Tooltip>
         </div>
         <div style="width: 100px; float:right;">
          <Tooltip title="Edit">
            <IconButton aria-label="Edit">
              <EditIcon>
              </EditIcon>
            </IconButton>
          </Tooltip>
          </div>
         </div> 


        ) : (
          <Tooltip title="Filter list">
            <IconButton aria-label="Filter list">
              <FilterListIcon />
            </IconButton>
          </Tooltip>
        )}


      </div>
    </Toolbar>
  );
};

I received the error when I set the width to 100px and float to right in my delete button and edit button. The code will work if I never set the width and float. However,it div by up down instead of side by side. Anyone know how to solve this issue?

Share Improve this question asked Apr 5, 2019 at 3:54 phoonphoon 3691 gold badge6 silver badges24 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

That is not how you define inline styles in JSX.

The style attribute accepts a JavaScript object with camelCased properties rather than a CSS string.

Try this instead:

<div style={{ width: '100px', float: 'right' }}>

本文标签: javascriptUncaught Invariant Violation Minified React errorStack Overflow