3

I feel like i'm missing some crucial benefits of this static thing in react.

export default class ComponentName extends Component { static someMethod = () => { } static someVariable = { a: 'b' } render() { return ( <View> <Text>ComponentName</Text> </View> ); } } 

Why would i use this instead of regular const functionName = () => {} or variables?

7
  • 1
    const functionName = () => {} will be copied for each instance, static will be defined once. Commented Apr 7, 2017 at 19:06
  • additionally, this isn't specific to react. it's specific to javascript classes. Commented Apr 7, 2017 at 19:08
  • okay, sounds like explicit advantage of static. Then why people don't use it all the time? Commented Apr 7, 2017 at 19:08
  • On what stats is your opinion regarding "people are not using it all the time" based? Commented Apr 7, 2017 at 19:10
  • no stats, just observations of opensource boilerplates Commented Apr 7, 2017 at 19:17

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.