Been experimenting with ReactVR and i have few doubts in handling events.As per the documentation in Cusors and Input,finding out the type of event is as easy as reading type
of the event.
Events coming into onInput can be further filtered by inspecting the type field, which will be one of 'MouseInputEvent', 'KeyboardInputEvent', 'TouchInputEvent', or 'GamepadInputEvent'
But in the below code event.type
gives undefined
.
_onInput(event) {
console.log(event.type);//undefined
}
i was eventually able to sniff the event type by doing
_onInput(event) {
let syntheticEvent = event.nativeEvent.inputEvent;
console.log(syntheticEvent.type);
}
Is this the expected behaviour or am i missing something.
Few related questions
- Do we have to sniff events with event.nativeEvent?
- How do we find out the target of the event, for eg if i am to bind
an
onInput
event to aPlane
, currently inspecting theevent.nativeEvent
gives thetarget
as a numerical value? Not helpful at all. Finally, the ReactJS way of calling events doesn't seem to work in ReactVR. For eg, in the former we would just
<Plane onInput={this._onInput} lit={true} />
But this doesnt work , in the latter we have to
<Plane onInput={(event) => this._onInput(event)} lit={true} />
Why is this?
Note:i have some exp with ReactJS and ZERO with React Native, i am guessing ReactVR inclines towards the latter pardon if it is obvious