Reinitializing noteIndex when fetching new notes (to avoid out of length indexes).

This commit is contained in:
Eric van der Vlist 2022-10-11 14:15:46 +02:00
parent 5a7402313e
commit 304c4d38b7
1 changed files with 37 additions and 35 deletions

View File

@ -77,6 +77,7 @@ const LocationInfo: React.FC<{}> = () => {
const findNotes = async () => {
setNotes(undefined);
setNoteIndex(0);
const metresPerDegree =
111111 * Math.cos((scope.center.lat * Math.PI) / 180);
const deltaDegrees = 2000 / metresPerDegree;
@ -249,7 +250,8 @@ const LocationInfo: React.FC<{}> = () => {
/>
</ConversationHeader>
<MessageList>
{notes.features[noteIndex].properties.comments.map(
{noteIndex < notes.features.length &&
notes.features[noteIndex].properties.comments.map(
(comment: any, index: number) => (
<Message
key={`${notes.features[noteIndex].properties.id}/${index}`}