I see this pattern a lot but I cant really figure ...
# javascript
s
I see this pattern a lot but I cant really figure out how to do the same from KotlinJS. Ie. how can I define a class and then export it in a decorated fashion?
Copy code
class MyComponent extends React.Component {
  render () {
    return <div className={this.props.classes.root} />;
  }
}

export default withStyles(styles)(MyComponent);
g
You cannot use JSX from Kotlin
s
That is an irrelevant detail
g
What is relevand than?
how to use export?
s
Everything other than the implementation of render
g
what exactly?
Work with modules described in docs https://kotlinlang.org/docs/reference/js-modules.html
s
Ie. how can I define a class and then export it in a decorated fashion?
g
class MyClass
public class exporte by default
you also can configure it with annotations
s
I cannot relate anything you write with my question. I gave a specific example of what I would love a kotlinjs version of.
g
kotlin-wrappers provide you Kotlin wrapper API to implement React component
withStyles is it some library method? doesn’t look as something from vanilla react
How to export somethin as module described in js-modules documentation
s
The documentation mentions the
default
keyword zero times and has only examples of exports of directly defined functions/classes. In the example both default is used and the exported function/class is the result of a function invocation.
g
This is part of ES6, so not supported directly by KotlinJS, Kotlin have only ES5 But it's not so important in this case, it's just that this class name will be exposed by default on import, see export default documentation
But if you want, you can just call it using js() function that will call any arbitrary js code
This is why I asked what is exactly not clear in this snippet