@@ -92,16 +92,37 @@ If the export is declard as a default export, then you would use ``"default"`` a
9292Taking [ react-native-qrcode-scanner] ( https://github.com/moaazsidat/react-native-qrcode-scanner ) as an example:
9393
9494To translate the example
95+
9596``` js
9697import QRCodeScanner from ' react-native-qrcode-scanner' ;
9798```
98- you would declare your function like
99+
100+ you would declare your function like
99101
100102``` fsharp
101103let inline qr_code_scanner (props : QRCodeScannerProps list) : ReactElement =
102104 ofImport "default" "react-native-qrcode-scanner" (keyValueList CaseRules.LowerFirst props) []
103105```
104106
107+ #### Fields of imported items
108+
109+ Some React components must be instantiated as follows in JS:
110+
111+ ``` js
112+ import { Select } from ' react-select'
113+ let render = () => < Select .Creatable options= {... } / >
114+ ```
115+
116+ In this case, you can also use ` ofImport ` to directly access the field of the imported item:
117+
118+ ``` fsharp
119+ // Import { Select } from "react-select" and then access the "Creatable" field
120+ ofImport "Select.Creatable" "react-select" myOptions []
121+
122+ // Also compatible with default imports
123+ ofImport "default.Creatable" "react-select" myOptions []
124+ ```
125+
105126#### Directly creating the element
106127
107128If you already have a reference to the imported component, then you can also use `` createElement `` .
@@ -113,6 +134,13 @@ let rnqs = importDefault "react-native-qrcode-scanner"
113134createElement(rnqs, (keyValueList CaseRules.LowerFirst props), [])
114135```
115136
137+ > Please note it's also OK to duplicate ` ofImport ` with same member and path. In this case, Fable will automatically group the imports.
138+
139+ ``` fsharp
140+ let foo1 = ofImport "default" "react-foo" { height = 25 } []
141+ let foo2 = ofImport "default" "react-foo" { height = 50 } []
142+ ```
143+
116144### 4. Use the creation function in your view code
117145
118146The function you declared in step 2 now behaves just like any other React component function.
0 commit comments