Skip to content

Brianna/step five#20

Draft
BCerki wants to merge 36 commits intobutton-inc:mainfrom
BCerki:brianna/step-five
Draft

Brianna/step five#20
BCerki wants to merge 36 commits intobutton-inc:mainfrom
BCerki:brianna/step-five

Conversation

@BCerki
Copy link

@BCerki BCerki commented Mar 3, 2022

No description provided.

Comment on lines +29 to +30
//@ts-ignore
const input = document.getElementById("newTodo").value
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions for how to do this better?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could

  • register an onChange={(event) => doSomething(event.target.value)} on the input field, to keep an always up-to-date state
  • or better, wrap the whole thing in a <form onSubmit={handleSubmit}>, the submit click event should have an array of elements as a target where you can retrieve your data

function TodoList(props: Props) {

const data = useFragment(
// underscore matches prop name, convention in this project to use _query if its of type Query (type comes from postgraphile)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Relay will enforce the name of the fragment starting with your default export's name, and ending with your data type (Query, Todo, etc. )

updateTodo(input: $input) {
todoEdge {
node {
completed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll need to fetch the id here, for Relay to update its local store
https://relay.dev/docs/guided-tour/updating-data/graphql-mutations/#updating-data-once-a-request-is-complete

This way if the request fails, the checkbox will uncheck itself on re-render

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

Successfully merging this pull request may close these issues.

2 participants