You could export factory function but not the resu...
# javascript
b
You could export factory function but not the resulting class
a
Factory functions that wrap react components? can you please aid me with a sample?
b
Copy code
private class Komponent: RComponent<RState, RProps> {...}

@JsExport
fun MyKomponent(props: RProps): RComponent<RState, RProps> = Komponent(...) // Or however you normally initialise it in kotlin react. Important bit is that you return your component downcasted as RComponent<RState, RProps>
a
This won't work. Actually that is a bit similar to what I have been doing. The requirement is to mark the React Component itself with
@JsExport
if you won't, your component's methods, get mangled and minified. You get errors like
el.render
is not a function
b
How about @JsExport on
internal class
?
Also try adding @PublishedApi annotation as well, see if that helps
a
Tried it. Doesn't work
Maybe I give
@PublishedApi
a try.
b
How about private constructor as suggested on the other thread?
a
Will report back
Haven't tried private constructor yet. But that will only disable instantiation from library consumers the Components will still be available. It is half a solution though, so I might give it a spin
Reporting back the combination of
internal
and
@PublishedApi
. It doesn't work too
Screenshot from 2020-12-02 05-48-36.png
Private constructor works, but again it does address only like a quater of the problem