简体   繁体   中英

Uncaught Invariant Violation: Minified React error

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?

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' }}>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM