Skip to content

Commit

Permalink
fix(react-web/Thumbnail): Cannot read property 'input' of undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
KerimRahman committed Jul 23, 2021
1 parent 86f6fab commit 6e3c5c4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/components/react-web/src/Thumbnail/Thumbnail.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { useState } from 'react';
import { useState } from 'react';
import PropTypes from 'prop-types';
import { helpers } from '@compassion-gds/elements';
/** @jsxRuntime classic */
/** @jsx jsx */
import { jsx } from '@emotion/core';
import { cx } from 'emotion';
import { useTheme } from 'emotion-theming';
import { useTheme } from "../hooks";
import { thumbnailStyles } from './Thumbnail.styles';
import image1 from './assets/image1.jpg';
import image2 from './assets/image2.jpg';
Expand All @@ -20,7 +18,7 @@ export const Thumbnail = ({ type, size, label, validator, ...props }) => {
const [selected, setSelected] = useState(image1);
console.log('selected =', selected);

const theme = useTheme().component.input;
const theme = useTheme();
const data = [
{
id: '1',
Expand Down Expand Up @@ -60,12 +58,12 @@ export const Thumbnail = ({ type, size, label, validator, ...props }) => {
];

return (
<div css={thumbnailStyles(theme)}>
<div css={thumbnailStyles(theme.component.input)}>
{selected ? <img src={selected} alt={selected.title} /> : null}
{data.map((obj) =>
selected === obj.img ? null : (
<div key={obj.id}>
<button onClick={() => setSelected(obj.img)}>
<button type="button" onClick={() => setSelected(obj.img)}>
<img src={obj.img} alt={obj.title} />
</button>
</div>
Expand Down

0 comments on commit 6e3c5c4

Please sign in to comment.