Skip to content

Commit

Permalink
fix: only render strings or numbers in external adaptors
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddieRidell authored Oct 17, 2023
1 parent 9e4a0e3 commit 3c337be
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/core/components/ExternalInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useMemo, useEffect, useState } from "react";
import styles from "./styles.module.css";
import getClassNameFactory from "../../lib/get-class-name-factory";
import { Field } from "../../types/Config";
Expand All @@ -18,6 +18,13 @@ export const ExternalInput = ({
const [data, setData] = useState<Record<string, any>[]>([]);
const [isOpen, setOpen] = useState(false);
const [selectedData, setSelectedData] = useState(value);
const keys = useMemo(
() =>
Object.keys(data).filter(
(key) => typeof data[key] === "string" || typeof data[key] === "number"
),
[data]
);

useEffect(() => {
(async () => {
Expand Down Expand Up @@ -85,7 +92,7 @@ export const ExternalInput = ({
<table>
<thead>
<tr>
{Object.keys(data[0]).map((key) => (
{keys.map((key) => (
<th key={key} style={{ textAlign: "left" }}>
{key}
</th>
Expand All @@ -106,7 +113,7 @@ export const ExternalInput = ({
setSelectedData(item);
}}
>
{Object.keys(item).map((key) => (
{keys.map((key) => (
<td key={key}>{item[key]}</td>
))}
</tr>
Expand Down

0 comments on commit 3c337be

Please sign in to comment.