diff options
author | Fabio Berger <me@fabioberger.com> | 2018-10-05 19:00:24 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-10-05 19:00:24 +0800 |
commit | f7aee9c7a9df36e20888c10616a249c2a79ed749 (patch) | |
tree | fd086c31e10ebfa012a1d7ecf7fb3f310bf18f64 | |
parent | e7de4b953fe8aaefee9c043679b021a485dc6dee (diff) | |
download | dexon-sol-tools-f7aee9c7a9df36e20888c10616a249c2a79ed749.tar dexon-sol-tools-f7aee9c7a9df36e20888c10616a249c2a79ed749.tar.gz dexon-sol-tools-f7aee9c7a9df36e20888c10616a249c2a79ed749.tar.bz2 dexon-sol-tools-f7aee9c7a9df36e20888c10616a249c2a79ed749.tar.lz dexon-sol-tools-f7aee9c7a9df36e20888c10616a249c2a79ed749.tar.xz dexon-sol-tools-f7aee9c7a9df36e20888c10616a249c2a79ed749.tar.zst dexon-sol-tools-f7aee9c7a9df36e20888c10616a249c2a79ed749.zip |
Remove containerId option and throw if passing in shouldOpenInNewTab with type ReactScroll
-rw-r--r-- | packages/react-shared/src/components/link.tsx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/packages/react-shared/src/components/link.tsx b/packages/react-shared/src/components/link.tsx index ee55cc642..e8a13d506 100644 --- a/packages/react-shared/src/components/link.tsx +++ b/packages/react-shared/src/components/link.tsx @@ -6,7 +6,7 @@ import { Link as ScrollLink } from 'react-scroll'; import { LinkType } from '../types'; import { constants } from '../utils/constants'; -export interface LinkProps { +interface LinkProps { to: string; type?: LinkType; shouldOpenInNewTab?: boolean; @@ -15,7 +15,6 @@ export interface LinkProps { onMouseOver?: (event: React.MouseEvent<HTMLElement>) => void; onMouseLeave?: (event: React.MouseEvent<HTMLElement>) => void; onMouseEnter?: (event: React.MouseEvent<HTMLElement>) => void; - containerId?: string; } export interface LinkState {} @@ -35,7 +34,6 @@ export class Link extends React.Component<LinkProps, LinkState> { onMouseOver: _.noop.bind(_), onMouseLeave: _.noop.bind(_), onMouseEnter: _.noop.bind(_), - containerId: constants.DOCS_CONTAINER_ID, }; private _outerReactScrollSpan: HTMLSpanElement | null; constructor(props: LinkProps) { @@ -43,6 +41,10 @@ export class Link extends React.Component<LinkProps, LinkState> { this._outerReactScrollSpan = null; } public render(): React.ReactNode { + if (this.props.type === LinkType.ReactScroll && this.props.shouldOpenInNewTab) { + throw new Error(`Cannot open LinkType.ReactScroll links in new tab. link.to: ${this.props.to}`); + } + const styleWithDefault = { textDecoration: 'none', cursor: 'pointer', @@ -91,7 +93,7 @@ export class Link extends React.Component<LinkProps, LinkState> { offset={0} hashSpy={true} duration={constants.DOCS_SCROLL_DURATION_MS} - containerId={this.props.containerId} + containerId={constants.DOCS_CONTAINER_ID} className={this.props.className} style={styleWithDefault} > |