Skip to content

Commit

Permalink
removed useRenderCount (it can be added back later if we care)
Browse files Browse the repository at this point in the history
  • Loading branch information
eXamadeus committed Mar 22, 2020
1 parent 6e2e6c2 commit d7983b0
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 42 deletions.
7 changes: 0 additions & 7 deletions pages/[event].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import { EventData } from '../server/data/events';
import { AuthButton } from '../shared/components/AuthButton/AuthButton';
import { Events } from '../shared/components/Events/Events';
import { useEvents } from '../store/events';
import { useRenderCount } from '../utils/useRenderCount';

export default withRedux(() => {
const { query, pushRoute, ready } = useRouter();
const { initialized, events } = useEvents();
const [displayedEvent, setDisplayedEvent] = useState<EventData | undefined>(undefined);
const renderCount = useRenderCount();

const eventId = parseStringParam(query?.event);
const eventData = events[eventId];
Expand All @@ -30,11 +28,6 @@ export default withRedux(() => {
return (
<>
<h1>{displayedEvent?.name || 'Event List'}</h1>
{renderCount && (
<pre>
{displayedEvent?.name} detail render count: {renderCount}
</pre>
)}
<AuthButton />
<Link href={'/'}>
<button>Back to index</button>
Expand Down
20 changes: 7 additions & 13 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@ import React from 'react';
import { withRedux } from '../next-utils/withRedux';
import { AuthButton } from '../shared/components/AuthButton/AuthButton';
import { Events } from '../shared/components/Events/Events';
import { useRenderCount } from '../utils/useRenderCount';

export default withRedux(() => {
const renderCount = useRenderCount();

return (
<>
<h1>Event List</h1>
{renderCount && <pre>Index render count: {renderCount}</pre>}
<AuthButton />
<Events />
</>
);
});
export default withRedux(() => (
<>
<h1>Event List</h1>
<AuthButton />
<Events />
</>
));
3 changes: 0 additions & 3 deletions shared/components/AuthButton/AuthButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';

import { useAuth, useUserName } from '../../../store/auth';
import { useRenderCount } from '../../../utils/useRenderCount';

export const AuthButton = () => {
const { loggedIn, login, logout } = useAuth();
const userName = useUserName();
const renderCount = useRenderCount();

return (
<>
Expand All @@ -18,7 +16,6 @@ export const AuthButton = () => {
</div>
{loggedIn !== 'unknown' && <div className={'user'}>User: {userName ?? '<empty>'}</div>}
(simulated 250ms latency on all requests)
{renderCount && `AuthButton render count: ${renderCount}`}
</div>
<style jsx>{`
div {
Expand Down
3 changes: 0 additions & 3 deletions shared/components/Events/Event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import React, { useState } from 'react';

import { EventData } from '../../../server/data/events';
import { useEvents } from '../../../store/events';
import { useRenderCount } from '../../../utils/useRenderCount';
import { Loader } from '../Loader/Loader';
import { Modal } from '../Modal/Modal';

export const Event = ({ event }: { event: EventData }) => {
const [open, setOpen] = useState(false);
const renderCount = useRenderCount();
const { loading } = useEvents();

return (
Expand All @@ -23,7 +21,6 @@ export const Event = ({ event }: { event: EventData }) => {
<button onClick={() => setOpen(true)}>View Details</button>
</div>
</Loader>
{renderCount && <pre>Event render count: {renderCount}</pre>}
</div>

{open && (
Expand Down
3 changes: 0 additions & 3 deletions shared/components/Events/Events.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import React from 'react';

import { useEvents } from '../../../store/events';
import { useRenderCount } from '../../../utils/useRenderCount';
import { Event } from './Event';

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

if (!initialized) return null;

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

return (
<>
{renderCount && <pre>Events render count: {renderCount}</pre>}
<div>
{eventIds.map(id => {
const event = events[id];
Expand Down
13 changes: 0 additions & 13 deletions utils/useRenderCount.ts

This file was deleted.

0 comments on commit d7983b0

Please sign in to comment.