Skip to content

Commit

Permalink
Throw rather than warn if observable mutated outside action
Browse files Browse the repository at this point in the history
  • Loading branch information
emereum authored and jzhan-canva committed Sep 27, 2024
1 parent ed9ab96 commit 3025fbd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/mobx/src/core/derivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
isComputedValue,
removeObserver
} from "../internal"
import { die } from "../errors"

export enum IDerivationState_ {
// before being run or (outside batch and not being observed)
Expand Down Expand Up @@ -141,7 +142,7 @@ export function checkIfStateModificationsAreAllowed(atom: IAtom) {
!globalState.allowStateChanges &&
(hasObservers || globalState.enforceActions === "always")
) {
console.warn(
die(
"[MobX] " +
(globalState.enforceActions
? "Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: "
Expand Down

0 comments on commit 3025fbd

Please sign in to comment.