Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to include static properties in a functional representation of a React component?

With ES6, it is possible to represent a React Component as a function.

So, the following component

class MyComponent extends React.Component {

  render() {
    <div>Hi</div>
  }

}

could also be represented as such

const MyComponent = (props) => (
   <div>Hi</div>
)

My question is whether the functional representation also allows for static properties. So, I'm wondering whether it is possible to represent the following component somehow as a function as well:

class MyComponentWithStaticProperty extends React.Component {

  static myProperty = {'hello': 'world'}

  render() {
    <div>Hi</div>
  }

}
like image 710
nburk Avatar asked Nov 29 '22 22:11

nburk


1 Answers

const MyComponent = (props) => (
   <div>Hi</div>
)

MyComponent.myProperty = {'hello': 'world'};
like image 184
Martin Dawson Avatar answered Dec 02 '22 10:12

Martin Dawson