Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload - uid is set even if provided - issue when fileList is immutable from ReduxToolkit selector | Cannot assign to read only property 'uid' of object '#<Object>' #29233

Closed
1 task done
sowka1995 opened this issue Feb 4, 2021 · 5 comments · Fixed by #29944
Assignees
Labels
🐛 Bug Ant Design Team had proved that this is a bug.

Comments

@sowka1995
Copy link

sowka1995 commented Feb 4, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Check reproduction link - there is my explanation of the problem.
The problem exists because I am using ReduxToolkit and getting attachements from the store (I am setting uid property) but this object is frozen (I want only show attached attachements (read-only))

What is expected?

There is react effect to set uid on each file if not provided

file.uid = (_a = file.uid) !== null && _a !== void 0 ? _a : "__AUTO__".concat(timestamp, "_").concat(index, "__");

should be sth like this

if (!file.uid)
   file.uid = "__AUTO__".concat(timestamp, "_").concat(index, "__");

What is actually happening?

Cannot assign to read only property 'uid' of object '#'

Environment Info
antd 4.12.2
React 16.3.1
System Windows
Browser Chrome/Edge chromium/Firefox

@jamie-box
Copy link

jamie-box commented Feb 4, 2021

Can confirm this issue on React 17.0.1 as well.

Environment Info
antd 4.12.2
React 17.0.1
System MacOS
Browser Chrome

@afc163 afc163 added the 🐛 Bug Ant Design Team had proved that this is a bug. label Feb 5, 2021
@jamie-box
Copy link

^bumping...

Hi Ant team, this is a blocking issue for my application. Please fix.

@remberi
Copy link

remberi commented Feb 22, 2021

I'm having the same problem, but downscaling to version 4.7.0 can fix it

@remberi
Copy link

remberi commented Feb 22, 2021

我的fileList是从父组件传递过来的,如果直接放到upload属性里面会报uid read only,可以从新赋值解决

componentDidMount() {
    if (this.props.fileList) {
      this.setState({
        fileList: this.props.fileList.map((item, index) => {
          return { uid: item.uid, name: item.name, status: item.status, url: item.url };
        }),
      });
    }
  }

@Guo-dalu
Copy link

I've met the same problem. When upgrading antd to v4.13.1, the problem disappeared. All works fine.

Maybe v4.12 has this problem and v4.13 has already fixed it?

升个级试试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Ant Design Team had proved that this is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants