fable-compiler / fable-react-native

Fable bindings and helpers for React Native projects
Apache License 2.0
49 stars 11 forks source link

Bad prototype for textInput? #17

Closed jacereda closed 5 years ago

jacereda commented 6 years ago

Shouldn't this take (children: React.ReactElement list) instead of text?

https://github.com/fable-compiler/fable-react-native/blob/b8585a183ff61bb6bfe288227d15cb100a2ef9e8/src/Fable.Helpers.ReactNative.fs#L1441

StachuDotNet commented 6 years ago

Why would it do that?

https://facebook.github.io/react-native/docs/textinput.html for reference.

On Fri, Dec 15, 2017 at 7:40 PM, jacereda notifications@github.com wrote:

Shouldn't this take (children: React.ReactElement list) instead of text?

https://github.com/fable-compiler/fable-react-native/blob/ b8585a183ff61bb6bfe288227d15cb100a2ef9e8/src/Fable.Helpers. ReactNative.fs#L1441

— 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/17, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3VvuJoqw8W07W89NVGYje_KY9aB27Qks5tAxGbgaJpZM4REKLi .

jacereda commented 6 years ago

I'm trying to run the iOS version of https://github.com/SAFE-Stack/SAFE-Nightwatch and I'm getting a Raw text cannot be used outside of a <Text> tag error. I think textInput isn't terminal and it can contain children.

jacereda commented 6 years ago

Maybe not a terminal though... What is the text argument supposed to be?

alfonsogarciacaro commented 6 years ago

I haven't used RN much myself, @forki have you used this function?

ddunlea commented 6 years ago

@jacereda I hit this issue myself some time ago. I implemented a work-around locally. If you use this alternate implementation for textInput, it should work

let inline textInput (props: ITextInputProperties list) (text:string): React.ReactElement =
    let valueProp = TextInput.TextInputProperties.Value text :> ITextInputProperties
    createElement(RN.TextInput, valueProp :: props, [])

I'll submit a PR for https://github.com/ddunlea/fable-react-native/commit/ee7c419eb16b705e317e298e3021a5f935db04b5

jacereda commented 6 years ago

Is the text argument really necessary? Wouldn't it be better to remove it completely and pass it as part of props?

ddunlea commented 6 years ago

I wrote it that way so as not to break the signature for existing callers. In my own code where I had no existing code to worry about, I'd been doing exactly what you said.