Skip to content

Commit 5f7c516

Browse files
committed
API: Validate Function blocks to find missing props
1 parent 93d43af commit 5f7c516

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/components/API/API.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@ import React from "react";
22

33
import styles from "./styles.module.css";
44

5+
function errorMessage(propertyName) {
6+
const what = "";
7+
const where = location.pathname;
8+
const message = `Missing property (${propertyName}) for (Function) imported from here: ${where}. Please add one!\n\n`;
9+
return message;
10+
}
11+
512
class Function extends React.Component {
613
render() {
714
const since = this.props.since;
815
const children = this.props.children;
16+
17+
const isRunningInDevelopmentMode = process.env.NODE_ENV !== "production";
18+
if (isRunningInDevelopmentMode) {
19+
// Doesn't look like more context can easily be obtained, so let's leave it at that...
20+
const where = location;
21+
const what = `Missing property (since) for (Function) imported from ${where}`;
22+
const message = `${what}`;
23+
if (!since) throw new Error(message);
24+
}
25+
926
const sinceBlock = (since && (
1027
<>
1128
<span className={styles.sinceBlock}>Available since: {since}</span>

0 commit comments

Comments
 (0)