Fork me on GitHub
#reagent
<
2019-04-05
>
Stefan06:04:29

Hi! I’m trying to create a React component that has a static function. Being new to clojurescript and reagent, I haven’t got a clue how to accomplish this. What I’m looking for is the equivalent of this JavaScript code:

class StyledScreen extends Component {
  static options(passProps) {
    return {
      topBar: { ... }
    }
  }
  ...
}

Stefan06:04:06

Any ideas? Thanks!!

Stefan07:04:43

Ok solved for now, turns out in my case the method doesn’t actually have to be static, even though the docs of the component says so. I’m still interested in the answer though for academic reasons 🙂

orestis08:04:52

Isn’t a static method in JavaScript just smoke and mirrors?

orestis08:04:01

(Honestly asking)

Stefan08:04:46

Kind of I guess. There is this ‘prototype’ thing. I’m not sure how this works actually. But suppose you define an ES6 class and pass it around to a library, and then the library instantiates it (once or more). In that case you would need to have the static function there if you want it to end up in the instance, right?