Skip to content

Commit

Permalink
refactored providedEvents to specificEventIds
Browse files Browse the repository at this point in the history
  • Loading branch information
eXamadeus committed Mar 22, 2020
1 parent 1c8047c commit 6e2e6c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/[event].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default withRedux(() => {
<button>Back to index</button>
</Link>
<h2>Related Events</h2>
<Events providedEvents={displayedEvent?.relatedEvents} />
<Events specificEventIds={displayedEvent?.relatedEvents} />
<h2>Event Details</h2>
<pre>{JSON.stringify(displayedEvent ?? {}, null, 2)}</pre>
</>
Expand Down
8 changes: 5 additions & 3 deletions shared/components/Events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import { useEvents } from '../../../store/events';
import { useRenderCount } from '../../../utils/useRenderCount';
import { Event } from './Event';

export const Events = ({ providedEvents }: { providedEvents?: string[] }) => {
export const Events = ({ specificEventIds }: { specificEventIds?: string[] }) => {
const { initialized, events } = useEvents();
const renderCount = useRenderCount();

if (!providedEvents && !initialized) return null;
if (!initialized) return null;

const eventIds = specificEventIds || Object.keys(events);

return (
<>
{renderCount && <pre>Events render count: {renderCount}</pre>}
<div>
{(providedEvents || Object.keys(events)).map(id => {
{eventIds.map(id => {
const event = events[id];

return event && <Event key={event.id} event={event} />;
Expand Down

0 comments on commit 6e2e6c2

Please sign in to comment.