質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -256,4 +256,152 @@
|
|
256
256
|
|
257
257
|
```
|
258
258
|
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
②試したこと
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
TypeError: doc.data is not a function
|
268
|
+
|
269
|
+
```
|
270
|
+
|
271
|
+
import React from 'react'
|
272
|
+
|
273
|
+
import { makeStyles } from '@material-ui/core/styles'
|
274
|
+
|
275
|
+
import Card from '@material-ui/core/Card'
|
276
|
+
|
277
|
+
import CardActionArea from '@material-ui/core/CardActionArea'
|
278
|
+
|
279
|
+
import CardActions from '@material-ui/core/CardActions'
|
280
|
+
|
281
|
+
import CardContent from '@material-ui/core/CardContent'
|
282
|
+
|
283
|
+
import CardMedia from '@material-ui/core/CardMedia'
|
284
|
+
|
285
|
+
import Button from '@material-ui/core/Button'
|
286
|
+
|
287
|
+
import Typography from '@material-ui/core/Typography'
|
288
|
+
|
289
|
+
import Divider from '@material-ui/core/Divider'
|
290
|
+
|
259
|
-
|
291
|
+
import { db } from '../../firebase/index'
|
292
|
+
|
293
|
+
const useStyles = makeStyles({
|
294
|
+
|
295
|
+
root: {
|
296
|
+
|
297
|
+
maxWidth: 345,
|
298
|
+
|
299
|
+
},
|
300
|
+
|
301
|
+
})
|
302
|
+
|
303
|
+
class ImgMediaCard extends React.Component {
|
304
|
+
|
305
|
+
constructor(props) {
|
306
|
+
|
307
|
+
super(props)
|
308
|
+
|
309
|
+
this.state = {
|
310
|
+
|
311
|
+
title: '',
|
312
|
+
|
313
|
+
url: '',
|
314
|
+
|
315
|
+
tag: '',
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
componentDidMount() {
|
324
|
+
|
325
|
+
const doc = db.collection('handsOn').get()
|
326
|
+
|
327
|
+
const data = doc.data()
|
328
|
+
|
329
|
+
if (data) {
|
330
|
+
|
331
|
+
this.setState({
|
332
|
+
|
333
|
+
title: data.title,
|
334
|
+
|
335
|
+
url: data.url,
|
336
|
+
|
337
|
+
tag: data.tag,
|
338
|
+
|
339
|
+
})
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
}
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
render() {
|
348
|
+
|
349
|
+
return (
|
350
|
+
|
351
|
+
<Card>
|
352
|
+
|
353
|
+
<CardActionArea>
|
354
|
+
|
355
|
+
<CardContent>
|
356
|
+
|
357
|
+
<Typography gutterBottom variant="h5" component="h2">
|
358
|
+
|
359
|
+
{this.state.title}
|
360
|
+
|
361
|
+
</Typography>
|
362
|
+
|
363
|
+
<Typography variant="body2" color="textSecondary" component="p">
|
364
|
+
|
365
|
+
{this.state.url}
|
366
|
+
|
367
|
+
</Typography>
|
368
|
+
|
369
|
+
</CardContent>
|
370
|
+
|
371
|
+
</CardActionArea>
|
372
|
+
|
373
|
+
<Divider />
|
374
|
+
|
375
|
+
<CardActions>
|
376
|
+
|
377
|
+
<Button size="small" color="primary">
|
378
|
+
|
379
|
+
{this.state.tag}
|
380
|
+
|
381
|
+
</Button>
|
382
|
+
|
383
|
+
<Button size="small" color="primary">
|
384
|
+
|
385
|
+
Learn More
|
386
|
+
|
387
|
+
</Button>
|
388
|
+
|
389
|
+
</CardActions>
|
390
|
+
|
391
|
+
</Card>
|
392
|
+
|
393
|
+
)
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
}
|
398
|
+
|
399
|
+
export default ImgMediaCard
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
```
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
![イメージ説明](7912e230798c1180d0cf39e0d12ab081.png)
|