Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

only handle Button onClick once #203

Merged
merged 1 commit into from
Oct 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/components/buttonsIndicators/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ export default class ThemedButton extends React.PureComponent<Props, {}> {
}

render () {
const { className, ...deepProps } = this.props
const { icon, text } = this.props
// separate DOM-related props out of props we want to pass to all children
const { className, onClick, ...deepProps } = this.props
const { icon, text } = deepProps
if (!onClick) {
console.warn('Button component not provided an onClick handler as a prop')
}
let ButtonComponent = this.getButtonComponent()

return (
<ButtonComponent className={className} {...deepProps}>
<ButtonComponent className={className} onClick={onClick} {...deepProps}>
{
text
? <StyledText {...deepProps}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ exports[`ModalBackupRestore tests basic tests matches the snapshot 1`] = `
>
<div
className="c19"
onClick={[Function]}
size="small"
type="subtle"
>
Expand All @@ -411,7 +410,6 @@ exports[`ModalBackupRestore tests basic tests matches the snapshot 1`] = `
>
<div
className="c19"
onClick={[Function]}
size="small"
type="subtle"
>
Expand All @@ -426,7 +424,6 @@ exports[`ModalBackupRestore tests basic tests matches the snapshot 1`] = `
>
<div
className="c19"
onClick={[Function]}
size="small"
type="subtle"
>
Expand All @@ -445,7 +442,6 @@ exports[`ModalBackupRestore tests basic tests matches the snapshot 1`] = `
>
<div
className="c19"
onClick={[Function]}
size="medium"
type="accent"
>
Expand Down
2 changes: 0 additions & 2 deletions src/features/rewards/welcomePage/__snapshots__/spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ exports[`WelcomePage tests basic tests matches the snapshot 1`] = `
<div
className="c20"
data-test-id="optInAction"
onClick={[Function]}
size="call-to-action"
type="subtle"
>
Expand Down Expand Up @@ -862,7 +861,6 @@ exports[`WelcomePage tests basic tests matches the snapshot 1`] = `
>
<div
className="c20"
onClick={[Function]}
size="call-to-action"
type="accent"
>
Expand Down