preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.63k stars 88 forks source link

No way to use it with Mobx #476

Closed FishOrBear closed 6 months ago

FishOrBear commented 6 months ago

Error: It is not allowed to use shouldComponentUpdate in observer based components.

import { signal } from "@preact/signals";
import { observer } from "mobx-react";
import { Component } from "preact";

signal(1);

@observer
export class App extends Component<{}, {}>{
    render()
    {
        return (
            <div>
                Hello World
            </div>
        );
    }
}
rschristian commented 6 months ago

Why would you use this with mobx? Generally they address the same problem and it'd make sense to use one or the other.

FishOrBear commented 6 months ago

Indeed, I am in the exploratory stage. Because singnals does not support object Store, I want to try it out. signals(0) is similar to mobx.observable.box(0)

rschristian commented 6 months ago

FWIW, I can't reproduce this: https://stackblitz.com/edit/vitejs-vite-rfbmef?file=src%2Fmain.jsx