-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
"Encountered two children with the same key" bug #2433
Comments
how this is related to relay? |
@jgcmarins Check mentioned PR. |
For people who experienced this error: Relay v1.7 - clientMutationId not removed yet Here is how to resolve this issue (kudos to https://github.com/este/este project) diff --git a/client/components/Posts/createPostMutation.js b/client/components/Posts/createPostMutation.js
index b9cd342..a86b424 100644
--- a/client/components/Posts/createPostMutation.js
+++ b/client/components/Posts/createPostMutation.js
@@ -1,50 +1,55 @@
import { commitMutation, graphql } from 'react-relay';
import { ConnectionHandler } from 'relay-runtime';
+const getClientMutationId = () => Date.now().toString(36);
+
const mutation = graphql`
mutation createPostMutation($input: CreatePostInput!) {
createPost(input: $input) {
postEdge {
node {
headline
body
id
rowId
}
}
+
+ clientMutationId
}
}
`;
export default function commit(environment, headline) {
return commitMutation(
environment,
{
mutation,
variables: {
input: {
post: {
headline,
body: 'mybody',
},
+ clientMutationId: getClientMutationId()
},
},
updater: (store) => {
// Get the payload returned from the server
const payload = store.getRootField('createPost');
const newEdge = payload.getLinkedRecord('postEdge');
// Add to connection (relay connections are used for pagination)
const hostProxy = store.get('query');
const conn = ConnectionHandler.getConnection(hostProxy, 'AppQuery_allPosts');
ConnectionHandler.insertEdgeAfter(conn, newEdge);
conn.setValue(conn.getValue('totalCount') + 1, 'totalCount')
},
onCompleted: response => {
console.log('response', response)
},
onError: err => console.error(err)
}
);
|
related to #2349 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is an old bug. Probably fixed in #2349
When I add two items with the same text prop, Relay will warn. I am not doing anything special in http://github.com/este/este.
It's clientMutationID thing. Care to comment, please?
The text was updated successfully, but these errors were encountered: