shirakaba / react-nativescript

React renderer for NativeScript
https://react-nativescript.netlify.com
MIT License
280 stars 14 forks source link

Check whether the event handler inheritance between View and ViewBase needs correcting #44

Closed shirakaba closed 4 years ago

shirakaba commented 4 years ago

The abstract <RCTView> (I need to rename it to <$View> for consistency...) class component takes in props for onLoaded and other events. Although they indeed belong to the NativeScript View component, some of the event names (loadedEventName and unloadedEventName, at first glance) also seem to be registered on ViewBase.

https://github.com/shirakaba/react-nativescript/blob/master/react-nativescript/src/components/View.ts#L23

https://github.com/NativeScript/NativeScript/blob/master/nativescript-core/ui/core/view-base/view-base.d.ts#L209

https://github.com/NativeScript/NativeScript/blob/master/nativescript-core/ui/core/view/view.d.ts#L515

I don't know whether this means that ViewBase also supports its own onLoaded and onUnloaded events, but either way, it shall need looking into.

shirakaba commented 4 years ago

Very satisfied with event handling and typings for event handlers in React NativeScript now, thanks to https://github.com/halfnelson/nativescript-source-to-jsx-def and NativeScript Vue's DOM interface that handles event listener attachment/removal very elegantly:

https://github.com/shirakaba/react-nativescript/blob/1a11127ed70194cbeb0b45be9dc38b2b9930251c/react-nativescript/src/nativescript-vue-next/runtime/nodes.ts#L187-L191