fable-compiler / fable-react-native

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

Not possible to have multi styled text #45

Closed fkhosrow closed 5 years ago

fkhosrow commented 5 years ago

Hello,

I would like to be able to have text with multi-styles. (for example some parts of the text is BOLD and some parts is italic). This requires nesting Text react elements inside another Text react element. See https://facebook.github.io/react-native/docs/text.

However, the Fable wrapper for text takes a list of TextProperties and a string text. There would need to be another API to take a list of TextProperties and other text elements. Would you be able to suggest a workaround?

Thanks for your help.

fkhosrow commented 5 years ago

I fixed this issue by creating my own wrapper: let inline nestedText (props : TextProperties list) (children : Fable.Import.React.ReactElement list): Fable.Import.React.ReactElement = createElement(Fable.Import.ReactNative.Globals.Text, props, children).

Closing this as adding this wrapper was very easy.