1
這是我建立了一個LoremPixel
組件:LoremPixel組件總是呈現相同的圖像
export default function LoremPixel({ url = 'http://lorempixel.com', width = 200, height = 400, alt = 'Placeholder image' }) {
const src = `${url}/${width}/${height}`;
return (<img className={centerImage} src={src} alt={alt} />);
}
const { string, number, oneOf } = PropTypes;
LoremPixel.propTypes = {
url: string,
height: oneOf(string, number),
width: oneOf(string, number),
alt: string,
};
我應該得到的寬度200,高度400每一次隨機圖像,而是我總是看到相同的圖像在我所有的LoremPixel
組件。
我把它在我的組件,如:
return (
<Card containerStyle={containerStyle}>
<CardHeader
title={title}
style={headerRootStyle}
textStyle={cardHeaderTextStyle}
titleStyle={titleStyle}
/>
<span className={authorStyle}>{author}</span>
<CardMedia>
<LoremPixel width={200} height={100} />
</CardMedia>
<CardText style={textStyle}>
<LoremIpsum />
</CardText>
<CardActions style={actionsStyle}>
<FlatButton label="Buy Now" />
</CardActions>
</Card>
);
從Book
組件被稱爲在Bookshelf
組件:
Books = books.map(book => (<div
key={uuid.v4()}
className={colFixedWidth}
{...firstChild}
{...secondChild}
>
<Book {...book} />
</div>),
);
不錯,它現在有效。 – vamsiampolu