Skip to content

TimelineList throws an error due to key prop being spread instead of explicitly passed #2666

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

Open
SimeonKostov opened this issue May 18, 2025 · 0 comments

Comments

@SimeonKostov
Copy link

The error below is thrown when using TimelineList.

 (NOBRIDGE) ERROR  Warning: A props object containing a "key" prop is being spread into JSX:
  let props = {key: someKey, format24h: ..., overlapEventsSpacing: ..., rightEdgeSpacing: ..., scrollToFirst: ..., scrollToNow: ..., date: ..., events: ..., initialTime: ..., scrollOffset: ..., onChangeOffset: ..., showNowIndicator: ..., numberOfDays: ..., timelineLeftInset: ...};
  <Timeline {...props} />
React keys must be passed directly to JSX without using spread:
  let props = {format24h: ..., overlapEventsSpacing: ..., rightEdgeSpacing: ..., scrollToFirst: ..., scrollToNow: ..., date: ..., events: ..., initialTime: ..., scrollOffset: ..., onChangeOffset: ..., showNowIndicator: ..., numberOfDays: ..., timelineLeftInset: ...};
  <Timeline key={someKey} {...props} />

The key prop is defined in the _timelineProps and then spread into <Timeline {..._timelineProps} />

const _timelineProps = {
...timelineProps,
key: item,
date: dropRight(weekDates, numberOfDaysToDrop),
events: flatten(dropRight(weekEvents, numberOfDaysToDrop)),
scrollToNow: _isToday && isInitialPage && scrollToNow,
initialTime: !_isToday && isInitialPage ? initialTime : undefined,
scrollToFirst: !_isToday && isInitialPage && scrollToFirst,
scrollOffset: timelineOffset,
onChangeOffset: onTimelineOffsetChange,
showNowIndicator: _isToday && showNowIndicator,
numberOfDays,
timelineLeftInset
};
if (renderItem) {
return renderItem(_timelineProps, {item, index, isCurrent, isInitialPage, isToday: _isToday});
}
return (
<>
<Timeline {..._timelineProps}/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant