Skip to content

Instantly share code, notes, and snippets.

@barbaracassani
Last active August 12, 2020 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barbaracassani/b47b4827365646b27d220b2d96abd08e to your computer and use it in GitHub Desktop.
Save barbaracassani/b47b4827365646b27d220b2d96abd08e to your computer and use it in GitHub Desktop.
Simple gallery in React & Typescript, where images are loaded dynamically from an external list
import React, { Dispatch, SyntheticEvent } from "react";
function Button({ text, onClick }: { text: string; onClick: any }) {
return <button onClick={onClick}>{text}</button>;
}
export default Button;
const images = [
{
url: "20_02.jpg",
caption: "Pier",
alt: "Pier",
},
{
url: "20_05.jpg",
caption: "Solitary tree",
alt: "Tree",
},
{
url: "20_07.jpg",
caption: "Sausage dog",
alt: "Sausage dog",
},
{
url: "20_17.jpg",
caption: "Daffodils",
alt: "Daffodils",
},
{
url: "20_21.jpg",
caption: "Branches and flowers",
alt: "Branches and flowers",
},
];
export default images;
export const count = images.length;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment