Skip to content

Commit

Permalink
feat: Link support target props
Browse files Browse the repository at this point in the history
  • Loading branch information
kelp404 committed Apr 5, 2023
1 parent 768e561 commit 2cfc277
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/web.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion lib/components/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const singleInstance = require('../single-instance');

module.exports = class Link extends React.PureComponent {
static propTypes = {
target: PropTypes.string,
to: PropTypes.oneOfType([
PropTypes.string.isRequired,
PropTypes.shape({
Expand All @@ -13,13 +14,17 @@ module.exports = class Link extends React.PureComponent {
]).isRequired,
};

static defaultProps = {
target: undefined,
};

constructor(props) {
super(props);
this.onClick = this.onClick.bind(this);
}

onClick(event) {
if (event.metaKey) {
if (event.metaKey || this.props.target) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "capybara-router",
"version": "2.11.0",
"version": "2.12.0",
"description": "Unfancy react router without flux and redux.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 2cfc277

Please sign in to comment.