-
Notifications
You must be signed in to change notification settings - Fork 65
Add support for using EventListener values in a ReactSpec with access to ReactThis #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report. I see two potential solutions here.
|
Storing the handlers in the state works with one caveat– you generally want to be able to write to the state and props, so the tracked effects in the handler includes I had to write a coercion function to get types to unify since removing the handler doesn't actually trigger write effects: removeEventWriteAccess :: forall e. EventListener (state :: ReactState ( write :: Write, read :: Read ) | e) -> EventListener (state :: ReactState (read :: Read) | e)
removeEventWriteAccess = unsafeCoerce |
Thanks for trying this out. Good point regarding the effects. The PS - Would |
Oh yeah, looks like |
Welcome! |
@iand675 is this okay to close? I am thinking |
I think the one other issue is that you have to put handlers in a |
Good point. I will keep this issue around. I might have some time soon to dig more into this. Thanks! |
As of #129, event handler references can be stored using purescript mechanism; e.g., #124 (comment) Please reopen if this is still an issue. |
I am trying to implement a component that listens to the
resize
event. Essentially it's just a variation on the cookbook example here. Here's the code that I'm trying to write, although it sort of seems to not be possible. The basic issue is that I can create anEventListener
, but I don't have a way to get access to theReactThis
inside of it. If I create a lambda that takes athis
argument instead of a fully saturated value, then it creates a different event listener when it tries to remove the event listener oncomponentWillUnmount
.The text was updated successfully, but these errors were encountered: