-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replaced item id keys with uuid ones #822
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import React from 'react'; | ||
import { CTFragment } from 'layout'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uuidv4 is totally a better name, nice pick! |
||
import { epub } from '../../../controllers'; | ||
import { ChapterTitle } from '../../../components'; | ||
import ChapterContent from './ChapterContent'; | ||
|
@@ -59,20 +60,22 @@ function ChapterInfo({ chapter, currChIndex, dispatch }) { | |
onSave={onSaveTitle} | ||
/> | ||
|
||
{contents.map((content, index) => ( | ||
<ChapterContent | ||
id={`ch-content-${id}-${index}`} | ||
key={`ch-content-${id}-${index}`} | ||
index={index} | ||
condition={condition} | ||
dispatch={dispatch} | ||
content={content} | ||
onInsert={onInsert(index)} | ||
onRemove={onRemove(index)} | ||
onTextChange={onTextChange(index)} | ||
onImageChange={onImageChange(index)} | ||
/> | ||
))} | ||
{contents.map((content, index) => { | ||
const uuid = uuidv4(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small readability improvement if you change the key to |
||
return ( | ||
<ChapterContent | ||
id={`ch-content-${id}-${index}`} | ||
key={`ch-content-${id}-${uuid}`} | ||
index={index} | ||
condition={condition} | ||
dispatch={dispatch} | ||
content={content} | ||
onInsert={onInsert(index)} | ||
onRemove={onRemove(index)} | ||
onTextChange={onTextChange(index)} | ||
onImageChange={onImageChange(index)} | ||
/> | ||
)})} | ||
|
||
<ChapterNewContent onInsert={onInsert(contents.length)} /> | ||
</CTFragment> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can rename the test id to include the component name like "ChapterContent-test-tag" in the case we ever have a test with lots of different components?