| 148 | tab: BookTab |
| 149 | } |
| 150 | export const Annotations: React.FC<AnnotationsProps> = ({ tab }) => { |
| 151 | const { book, section } = useSnapshot(tab) |
| 152 | |
| 153 | return ( |
| 154 | <> |
| 155 | <FindMatches tab={tab} /> |
| 156 | {/* with `key`, react will mount/unmount it automatically */} |
| 157 | {book.annotations |
| 158 | // seems to fix annotation flash when executing `next()` and `display()` |
| 159 | .filter((a) => a.spine.index === section?.index) |
| 160 | .map((annotation) => ( |
| 161 | <Annotation key={annotation.id} tab={tab} annotation={annotation} /> |
| 162 | ))} |
| 163 | {book.definitions.map((definition) => ( |
| 164 | <Definition key={definition} tab={tab} definition={definition} /> |
| 165 | ))} |
| 166 | </> |
| 167 | ) |
| 168 | } |