-
Notifications
You must be signed in to change notification settings - Fork 0
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
jc - Patch form that creates commons to supply startingDate
to POST.
#50
Conversation
import BasicLayout from "main/layouts/BasicLayout/BasicLayout"; | ||
import CommonsTable from 'main/components/Commons/CommonsTable'; | ||
import { useBackend } from 'main/utils/useBackend'; | ||
//import { useCurrentUser } from 'main/utils/currentUser' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this commented import?
// Stryker disable next-line ArrayDeclaration : [columns] is a performance optimization | ||
const memoizedColumns = React.useMemo(() => columns, [columns]); | ||
const memoizedCommons = React.useMemo(() => commons, [commons]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't actually memoize the columns or commons variables. The reference returned by memoizedColumns
and memoizedCommons
will change whenever the reference to columns
or commons
changes, which defeats the point of trying to memoize these fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoot, sorry! Shouldn't have requested review, I forked and got a bunch of redundant files.
for (let readable of commons) { | ||
readable.startingDate = new Date(readable.startingDate).toLocaleString(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cleaner to do this formatting in the accessor rather than modifying the input data.
@@ -1,5 +1,6 @@ | |||
import { render, waitFor, fireEvent } from "@testing-library/react"; | |||
import OurTable from "main/components/OurTable"; | |||
//import OurTable from "main/components/OurTable"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented import
Closing, adding to #40. |
The
Commons
type was expanded in #30 to include astartingDate
member. The form dumps its elements into the body of a POST request to/api/commons/new
, so we need to make sure the elements have the correctid
(?) property. I'm struggling to figure out the internals ofreact-hook-form
, and which values it uses for the POST.Forked from @Jacqueskim's branch that implements the page that lists commons for ease of testing. So we should merge #40 first.
Addresses #36.