Skip to content

Removing borderTopWidth does not work #13913

@picodoth

Description

@picodoth

Do you want to request a feature or report a bug?
I want to report a bug.

What is the current behavior?

export default class App extends React.Component {
  state = {
    toggled: true,
    style: {
      border: "10px solid black"
    }
  };
  handleClick = () => {
    console.log("clicked");
    const style = { ...this.state.style };
    if (this.state.toggled) {
      style.borderTopWidth = 0;
    } else {
      delete style.borderTopWidth; // BUG: removing borderTopWidth does not work
    }
    this.setState({
      style,
      toggled: !this.state.toggled
    });
  };
  render() {
    const style = this.state.style;
    return (
      <div className="App" style={style}>
        <h1>Hello CodeSandbox</h1>
        <h2>Start editing to see some magic happen!</h2>
        <button onClick={this.handleClick}>button</button>
      </div>
    );
  }
}

test

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
https://codesandbox.io/s/34m3njok6p
What is the expected behavior?
Top border should be set back to 10px after deleting borderTopWidth.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.5.2
Mac Sierra 10.12.6
Version 69.0.3497.100 (Official Build)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions