Skip to content

Commit

Permalink
moving event listener to render method
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabiana Fonseca committed Jun 18, 2020
1 parent 64e32ad commit 54f0d02
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class CheckoutButtonExample extends Component<
> {
/**
* This component is the one that is referenced in the extension point. To use it
* as an example, in the component's life cycle, the method componentDidMount is used to
* add an event listener, which updates the state every time the order form changes. This
* order form is then passed to its children so as to render a table with the items.
*/
* as an example, we add an event listener, which updates the state every time the
* order form changes. This order form is then passed to its children so as to render
* a table with the items.
*/
constructor(props: any) {
super(props)
this.state = {
Expand All @@ -26,11 +26,8 @@ class CheckoutButtonExample extends Component<
)
}

componentDidMount() {
this.listenOrderFormUpdated()
}

render() {
this.listenOrderFormUpdated()
return <CustomButton {...this.state.orderForm!} />
}
}
Expand Down

0 comments on commit 54f0d02

Please sign in to comment.