purescript-halogen-hooks icon indicating copy to clipboard operation
purescript-halogen-hooks copied to clipboard

Emulating initalState function for Hooks

Open jterbraak opened this issue 3 years ago • 1 comments

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

jterbraak avatar Sep 26 '22 15:09 jterbraak

Hi @jterbraak! Thanks for opening this PR. I'm on vacation until October 9, and I can take a thorough look at this then.

thomashoneyman avatar Sep 29 '22 10:09 thomashoneyman