purescript-halogen-hooks
purescript-halogen-hooks copied to clipboard
Emulating initalState function for Hooks
Turns out my previous fix only papers over the real issue in #73.
Halogen does not seem to guarantee the order in which HalogenQ fires. It's possible that Receive or Query arrive before Initialize. This means that the HookState has to be ready before evalHook is ever called. mkInitialState contains most of the old Initialize step code.
This PR adds the mkInitialState function which is an analog to initialState in vanilla Halogen. Given a Hook and the input it constructs the HookState required for evalHook.
Unfortunately this is a big change and I had to touch every test. It also slightly changes the behavior:
- the initial render is actually valid instead of just an empty text node
- UseMemo now also runs before the Initialize-step
Hi @jterbraak! Thanks for opening this PR. I'm on vacation until October 9, and I can take a thorough look at this then.