@kaspernj/api-maker 1.0.173 → 1.0.174

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/link.jsx +12 -6
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  ]
17
17
  },
18
18
  "name": "@kaspernj/api-maker",
19
- "version": "1.0.173",
19
+ "version": "1.0.174",
20
20
  "description": "",
21
21
  "main": "index.js",
22
22
  "repository": {
package/src/link.jsx CHANGED
@@ -5,17 +5,23 @@ export default class Link extends React.PureComponent {
5
5
  const {to, onClick, ...restProps} = this.props
6
6
 
7
7
  return (
8
- <a href={to} {...restProps} onClick={onClick || this.onLinkClicked} />
8
+ <a href={to} {...restProps} onClick={this.onLinkClicked} />
9
9
  )
10
10
  }
11
11
 
12
- onLinkClicked = (e) => {
13
- e.preventDefault()
12
+ onLinkClicked = (e, ...restArgs) => {
13
+ const {onClick} = this.props
14
14
 
15
- const history = global.apiMakerConfigGlobal?.history
15
+ if (onClick) onClick(e, ...restArgs)
16
16
 
17
- if (!history) throw new Error("History hasn't been set in the API maker configuration")
17
+ if (!e.defaultPrevented) {
18
+ e.preventDefault()
18
19
 
19
- history.push(this.props.to)
20
+ const history = global.apiMakerConfigGlobal?.history
21
+
22
+ if (!history) throw new Error("History hasn't been set in the API maker configuration")
23
+
24
+ history.push(this.props.to)
25
+ }
20
26
  }
21
27
  }