Skip to content

Commit

Permalink
fix: correct logic for checking function definition validity
Browse files Browse the repository at this point in the history
Co-authored-by: Kris Kenny <[email protected]>
  • Loading branch information
zstix and moonlight-komorebi committed Sep 2, 2021
1 parent 46294d9 commit 053becf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/FunctionDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import CodeDef from './CodeDef';
import { graphql } from 'gatsby';

const FunctionDefinition = ({ className, arguments: params, returnValue }) => {
if (!params.length && !returnValue && !returnValue.length) {
const hasParams = params.length;
const isReturnArray = Array.isArray(returnValue);
const hasReturn =
(isReturnArray && returnValue.length) || (!isReturnArray && returnValue);

if (!hasParams && !hasReturn) {
return null;
}

Expand Down

0 comments on commit 053becf

Please sign in to comment.