fable-react-native icon indicating copy to clipboard operation
fable-react-native copied to clipboard

Working with gestures

Open thitemple opened this issue 7 years ago • 2 comments

Hey there, I'm trying to work with some animation stuff and I'm having some difficulties. You may have seen my PR alread but I do have another issue that I'd like to understand how to fix it.

The interface IViewProperties inherits from IGestureResponderHandlers

https://github.com/fable-compiler/fable-react-native/blob/143d057d002bb463179da191b67ba522413919d6/src/Fable.Helpers.ReactNative.fs#L427

And I was wondering how I could pass it to the view. I began creating an object:

let panResponderConfig = createEmpty<Fable.Import.ReactNative.PanResponderCallbacks>
let panResponder = RN.PanResponder.create(panResponderConfig)

But then, how am I suppose to pass panResponder.panHandlers to the view?

Usually with javascript this is done this way:

this._panResponder = PanResponder.create({ .... })
<View {...this._panResponder.panHandlers}>....</View>

How can I replicate JavaScript's spread operator and how can I pass that to IViewProperties?

Thanks

thitemple avatar Aug 14 '18 18:08 thitemple

Cc @alfonsogcnunez

Thiago Temple [email protected] schrieb am Di., 14. Aug. 2018, 20:56:

Hey there, I'm trying to work with some animation stuff and I'm having some difficulties. You may have seen my PR alread https://github.com/fable-compiler/fable-react-native/pull/36 but I do have another issue that I'd like to understand how to fix it.

The interface IViewProperties inherits from IGestureResponderHandlers

https://github.com/fable-compiler/fable-react-native/blob/143d057d002bb463179da191b67ba522413919d6/src/Fable.Helpers.ReactNative.fs#L427

And I was wondering how I could pass it to the view. I began creating an object:

let panResponderConfig = createEmpty<Fable.Import.ReactNative.PanResponderCallbacks> let panResponder = RN.PanResponder.create(panResponderConfig)

But then, how am I suppose to pass panResponder.panHandlers to the view?

Usually with javascript this is done this way:

this._panResponder = PanResponder.create({ .... }) <View {...this._panResponder.panHandlers}>....</View>

How can I replicate JavaScript's spread operator and how can I pass that to IViewProperties?

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fable-compiler/fable-react-native/issues/37, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNCXSx6Ypi_lDKcIMRFpk-xxI9f5Cks5uQx1TgaJpZM4V8_iC .

forki avatar Aug 15 '18 05:08 forki

There's no equivalent to the object spread operator in Fable, but you should be able to use Object.assign directly. Apparently there's as a createElementWithObjProps helper in the code that helps you do that (as in here). Haven't tested it but maybe something like this works?

createElementWithObjProps(RN.View, JS.Object.assign(createEmpty<ob>, panResponder.panHandlers)

alfonsogarciacaro avatar Aug 22 '18 00:08 alfonsogarciacaro