re-frame icon indicating copy to clipboard operation
re-frame copied to clipboard

v1.0.0-rc2 throws error on React Native Expo

Open jgoodhcg opened this issue 4 years ago • 8 comments

Error message

addEventListener and attachEvent are unavailable

Other info

I was working on updating deps and adding deps.edn support for projects created with this create kit.

v1.0.0-rc2 throws the error above when the app first starts. v0.12.0 works fine.

jgoodhcg avatar May 24 '20 20:05 jgoodhcg

Thanks for the report @jgoodhcg, you've indeed found a bug 🐛 👍

This error is occurring here in the google closure library due to my unconditional use of the goog events api here.

The fix will be to first check that the environment (e.g. react native expo) supports the event APIs prior to calling it. We'll get this done in 1.0.0-rc3.

superstructor avatar May 26 '20 00:05 superstructor

This might be fixed by #615 so I have released 1.0.0-rc3 and left this issue open for feedback @jgoodhcg

superstructor avatar Jun 26 '20 23:06 superstructor

It looks like there is still a problem using 1.0.0.-rc3.

jgoodhcg avatar Jun 29 '20 23:06 jgoodhcg

The problem stills on 1.0.0-rc5. Version 0.12.0 works fine.

ghost avatar Jul 05 '20 02:07 ghost

In 1.0.0-rc6 we have added a try/catch that ignores the exception on environments that do not support addEventListener via the goog.events/listen API (e.g. React Native).

This fixes the issue but does mean that in React Native :loaded? in settings will never be set to true, so you'll continue to get superfluous duplicate event handler warnings when hot reloading code (e.g. via shadow-cljs, figwheel etc).

If you have any suggestions on the following please let us know @neural-works @jgoodhcg

  1. What is a good way for re-frame to detect that it is in the React Native environment ?
  2. Is there an alternative in React Native to goog.events/listen on js/self (i.e. the global object, usually js/window) to listen for the "load" event ? Or in other words, to execute a fn when all scripts have loaded ?

superstructor avatar Jul 06 '20 06:07 superstructor

Reopened awaiting response to above. Any feedback on above two questions @neural-works @jgoodhcg on how to detect being in React Native ?

superstructor avatar Jul 19 '20 22:07 superstructor

I have not had the to develop a library that runs on all the platforms , but a quick google search found this option for detecting environment.

I've not seen anything for executing a function when scripts load. There should be some example in expo.

jgoodhcg avatar Jul 25 '20 17:07 jgoodhcg

Updated to 1.1.1 today and it seems to be working :smile:. Thanks!

jgoodhcg avatar Sep 07 '20 17:09 jgoodhcg