infinum / datx

DatX is an opinionated JS/TS data store. It features support for simple property definition, references to other models and first-class TypeScript support.
https://datx.dev
MIT License
139 stars 7 forks source link

Error: [MobX] Cannot apply `@action` to `t.prototype.removeOne` #1180

Closed davinci2015 closed 1 year ago

davinci2015 commented 1 year ago

Used libraries

mobx, mobx-react, datx, datx-jsonapi

Library version(s)

datx-jsonapi ^1.1.4, datx ^1.1.4, mobx ^6.9.0, mobx-react ^7.6.0

Sample API response (if relevant)

No response

Environments with the issue

Node v18.12.1, React-Native v0.71.8

Environments without the issue

No response

Current behavior

I get the following error after updating to Mobx 6.9.0.

Screenshot 2023-05-20 at 16 33 12
Error: [MobX] Cannot apply '@action' to 't.prototype.removeOne':
The field is already decorated with '@action'.
Re-decorating fields is not allowed.
Use '@override' decorator for methods overridden by subclass

There's similar issue related to another library (mobx-state-tree) https://github.com/mobxjs/mobx-state-tree/issues/1653

Expected behavior

Mentioned error is not happening and the application is running properly.

Reproduction steps

No response

DarkoKukovec commented 1 year ago

Hi @davinci2015 MobX v6 is not supported on DatX v1. There were some signifficant changes between v5 and v6 and everything is handled in DatX v2, but since v1 was already in maintenance mode at that point, there was no point in adding the support.

DarkoKukovec commented 1 year ago

If you want to use the latest mobx, you'll need to update to v2.

As a minimal set of changes for this, you can check the following pages in the docs: https://datx.dev/docs/migration-guide/breaking-changes https://datx.dev/docs/migration-guide/from-v1#short-term-migration

davinci2015 commented 1 year ago

Thank you for the info and for providing links! I will close the issue.

DarkoKukovec commented 1 year ago

Just one additional info. If you decide to go the v1->v2 upgrade route, we have some codemods that might also help: https://datx.dev/docs/migration-guide/codemods