Skip to content

Commit

Permalink
Add auto change radius to Circle
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-ES committed Sep 12, 2016
1 parent f4206e7 commit 8eaa28a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Circle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class Circle extends React.Component<CircleProps, CircleState> {
lng: nextProps.lng,
});
}

if (nextProps.radius !== this.props.radius) {
this.setRadius(nextProps.radius);
}
}

public render(): JSX.Element {
Expand Down Expand Up @@ -93,6 +97,11 @@ export class Circle extends React.Component<CircleProps, CircleState> {
const { circle } = this;
circle.setCenter(point);
}

private setRadius(radius: number): void {
const { circle } = this;
circle.setRadius(radius);
}
}

// make the Circle component the default export
Expand Down

0 comments on commit 8eaa28a

Please sign in to comment.