Relay: __clientField directive sets field to undefined

Created on 15 Jul 2018  路  6Comments  路  Source: facebook/relay

Client schema is super awesome. I recommend this article https://medium.com/@matt.krick/replacing-redux-with-relay-47ed085bfafe.

However, there is a little bug or a feature, not sure. Note I have to use alias to get original text value, because @__clientField(handle: "draftText") sets the text to undefined, for some reason.

Am I doing something wrong or not?

screen shot 2018-07-15 at 16 16 00

Most helpful comment

I don't think this is a bug, you just have to set value to payload.handleKey in handler

record.setValue(record.getValue(payload.fieldKey), payload.handleKey)

All 6 comments

Do u have a handler for draftText?

Sure I have. It works as expected. Except text is undefined for some reason.

https://github.com/este/este/blob/master/components/app/createRelayEnvironment.js#L58

@steida you have tried debugging right here https://github.com/este/este/blob/master/components/app/handlerProvider.js#L25, in the value? You shouldn't be using the JSON.parse to parse the value, for then, uses it on record.setValue?

Sorry, but I don't see where I am using JSON.parse. Or I don't understand your comment.

I don't think this is a bug, you just have to set value to payload.handleKey in handler

record.setValue(record.getValue(payload.fieldKey), payload.handleKey)

@BorisTB Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

piotrblasiak picture piotrblasiak  路  3Comments

brad-decker picture brad-decker  路  3Comments

MartinDawson picture MartinDawson  路  3Comments

bondanherumurti picture bondanherumurti  路  3Comments

rayronvictor picture rayronvictor  路  3Comments