adopted-ember-addons / adopted-ember-addons/ember-changeset

You attempted to update `_errors` on `changeset:[object Object]`

未關閉
#573 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
425
分支
136
PR 合併指標
30 天內沒有已合併 PR

描述

Not sure if this is a bug or a feature request - happy to provide a reproduction if needed, would really appreciate some feedback.

We have been using the following pattern in our components for a while now:

``` js
import Component from '@glimmer/component';
import Changeset from 'ember-changeset';
import lookupValidator from 'ember-changeset-validations';
import InfoValidations from '../validations/info';

export default class InfoFormComponent extends Component {
constructor() {
super(...arguments);

this.changeset = new Changeset(
this.args.model,
lookupValidator(InfoValidations),
InfoValidations
);

this.changeset.validate();
}
}
```

This causes the following deprecation warning in Ember 3.23:

```
DEPRECATION: You attempted to update `_errors` on `changeset:[object Object]`, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

`_errors` was first used:

- While rendering:
application
index
info-form
```

I believe this is because internally the changeset is tracking `_errors` and it is being updated by the validate call.

How do you suggest we restructure things given we would like to immediately validate the changeset when the component is invoked?

Alternatively do you think it's worth considering adding an option to ember-changeset to immediately validate a changeset when initialized?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。