Created
April 17, 2023 03:32
-
-
Save mike-pete/58c803cd6a2ac1ed361ac82dd8621648 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useRecords = () => { | |
const [record, setRecord] = useState<Record<string, string>>({ | |
'record 1': 'foo', | |
'record 2': 'foo', | |
'record 3': 'bar', | |
}) | |
return { | |
get uniqueRecords() { | |
const uniqueRecords = new Set(Object.values(record)) | |
return [...uniqueRecords] | |
}, | |
} | |
} | |
const DisplayRecords: React.FC = () => { | |
const { uniqueRecords } = useRecords() | |
return ( | |
<> | |
{uniqueRecords.map((record) => ( | |
<p key={record}>{record}</p> | |
))} | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment