aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-shared/src/ts/components/markdown_section.tsx
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-08 23:19:39 +0800
committerFabio Berger <me@fabioberger.com>2018-03-08 23:19:39 +0800
commit8057f4a678f5e4c00241ec9b15bd9d4dfc3588df (patch)
treead08f11e6e2ac0d8fea0708652e3defe3ad89df6 /packages/react-shared/src/ts/components/markdown_section.tsx
parentf9ec8a0828b7f75276491e496a4ae62e5301a6f3 (diff)
downloaddexon-sol-tools-8057f4a678f5e4c00241ec9b15bd9d4dfc3588df.tar
dexon-sol-tools-8057f4a678f5e4c00241ec9b15bd9d4dfc3588df.tar.gz
dexon-sol-tools-8057f4a678f5e4c00241ec9b15bd9d4dfc3588df.tar.bz2
dexon-sol-tools-8057f4a678f5e4c00241ec9b15bd9d4dfc3588df.tar.lz
dexon-sol-tools-8057f4a678f5e4c00241ec9b15bd9d4dfc3588df.tar.xz
dexon-sol-tools-8057f4a678f5e4c00241ec9b15bd9d4dfc3588df.tar.zst
dexon-sol-tools-8057f4a678f5e4c00241ec9b15bd9d4dfc3588df.zip
Add back strict null checks to react-shared package and fix issues
Diffstat (limited to 'packages/react-shared/src/ts/components/markdown_section.tsx')
-rw-r--r--packages/react-shared/src/ts/components/markdown_section.tsx17
1 files changed, 12 insertions, 5 deletions
diff --git a/packages/react-shared/src/ts/components/markdown_section.tsx b/packages/react-shared/src/ts/components/markdown_section.tsx
index 682b6ef8f..95dc83eaf 100644
--- a/packages/react-shared/src/ts/components/markdown_section.tsx
+++ b/packages/react-shared/src/ts/components/markdown_section.tsx
@@ -19,6 +19,12 @@ export interface MarkdownSectionProps {
githubLink?: string;
}
+interface DefaultMarkdownSectionProps {
+ headerSize: HeaderSizes;
+}
+
+type PropsWithDefaults = MarkdownSectionProps & DefaultMarkdownSectionProps;
+
export interface MarkdownSectionState {
shouldShowAnchor: boolean;
}
@@ -34,7 +40,8 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
};
}
public render() {
- const sectionName = this.props.sectionName;
+ const { sectionName, markdownContent, headerSize, githubLink } = this.props as PropsWithDefaults;
+
const id = utils.getIdFromName(sectionName);
return (
<div
@@ -47,7 +54,7 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
<div className="col lg-col-8 md-col-8 sm-col-12">
<span style={{ textTransform: 'capitalize', color: colors.grey700 }}>
<AnchorTitle
- headerSize={this.props.headerSize}
+ headerSize={headerSize}
title={sectionName}
id={id}
shouldShowAnchor={this.state.shouldShowAnchor}
@@ -55,9 +62,9 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
</span>
</div>
<div className="col col-4 sm-hide xs-hide right-align pr3" style={{ height: 28 }}>
- {!_.isUndefined(this.props.githubLink) && (
+ {!_.isUndefined(githubLink) && (
<a
- href={this.props.githubLink}
+ href={githubLink}
target="_blank"
style={{ color: colors.linkBlue, textDecoration: 'none', lineHeight: 2.1 }}
>
@@ -68,7 +75,7 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
</div>
<hr style={{ border: `1px solid ${colors.lightestGrey}` }} />
<ReactMarkdown
- source={this.props.markdownContent}
+ source={markdownContent}
escapeHtml={false}
renderers={{
code: MarkdownCodeBlock,