mobx-keystone is awesome and way easier to use for typesafe domain modeling than MST.
i've managed to hit some unexpected behavior when using it in combination with react and mobx-react-lite.
what i'd like to do: there's an action on a model i want to involve in a onClick callback:
import { observer } from "mobx-react-lite";
import { useStore } from "./Provider";
import "./styles.css";
function App() {
const { foo, setFoo } = useStore();
return (
<>
<button onClick={() => setFoo(true)}>set foo to true</button>
{foo && <div>foo is true now</div>}
</>
);
}
export default observer(App);
here, when i click the button, it throws:
TypeError: Invalid value used as weak map key
with a stack trace pointing to getActionMiddlewares and wrappedAction.
i've put together a very minimal repro here. thanks in advance for any advice you can provide-- also happy to help investigate and find a fix if this is a bug, provided a nudge in the right direction in the codebase.
mobx-keystoneis awesome and way easier to use for typesafe domain modeling than MST.i've managed to hit some unexpected behavior when using it in combination with
reactandmobx-react-lite.what i'd like to do: there's an action on a model i want to involve in a
onClickcallback:here, when i click the button, it throws:
with a stack trace pointing to
getActionMiddlewaresandwrappedAction.i've put together a very minimal repro here. thanks in advance for any advice you can provide-- also happy to help investigate and find a fix if this is a bug, provided a nudge in the right direction in the codebase.