Last active
September 6, 2018 23:50
-
-
Save ajcrites/0680d4766798089bfa58dd1b0c2c33aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example | |
export class ConstructorComponent extends React.Component<{ start: number }, { count: number }> { | |
// React Components takes `props` as a constructor argument. You can set default state here as well. | |
constructor(props) { | |
super(props); | |
this.state = { count: props.start }; | |
this.count = countService.count(); | |
this.positiveCount = this.count.pipe(filter(c => c > 0)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Better (imo) Example | |
import * as React from 'react'; | |
export class NoConstructorComponent extends React.Component<{ start: number }, { count: number }> { | |
state = { count: this.props.start }; | |
count = countService.count(); | |
positiveCount = this.count.pipe(filter(c => c > 0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment