That is correct, but two notes:
Also note that mobx-react-lite does support, and is built on hooks! But neat solution! (p.s. using
useState(() => cb())` or just `useState(cb) in the beginning will probably be more efficient
Yeah it should break (if you didn’t fork the fixed version of the sandbox), but theoretically it might be fixed if the bundle strategy in sandbox changed for example. The examples are not particular interesting, but the problem and solution strategy applies in general.
Sorry for the disappointing answer after waiting for long, but, thought a little about, and I think that is what I would go for too, setting a flag to indicate that a redirect is happening, I don’t see any direct problems if you can synchronously determine that a redirect needs to happen. If it can only be determined async (e.g. a product from a…
If I understand it correctly, I think it could work, but now you have bigger problems: 1. All call sides need to have inline-requires, which is very hard to keep track of and very easy to forget. 2. You can’t bundle your code with webpack or other bundler, as those would hoist the require’s anyway. 3. You are looking yourself into CommonJS specific semantics, which won’t work in ES module based environments