yahoo/react-i13n

object.assign changes props ordering and resulting in different attribute orders on the server and client

lalau opened this issue · 5 comments

lalau commented

I am tracing a checksum mismatch warning and noticed the props' key ordering is changed here:

var props = Object.assign({}, {
i13n: {
executeEvent: this.executeI13nEvent,
getI13nNode: this.getI13nNode
}
}, this.props);

I only see the issue happening in chrome and on certain executions of that object assign code. Technically the key ordering is not something we should rely on because it's unspecified according to the spec, but it seems that's what react is using to render the attribute when using the spread operator. Should we play it safe here to not use object.assign but a for in loop to preserve the original ordering?

A for in loop does not guarantee order preservation either.

lalau commented

That's true, but at least that's the de-facto standard of browsers to preserve insertion order, while object.assign seems more unpredictable. That's what I mean to play it safe. There isn't really a fix here except fixing the spread operator.

Hi @lalau thanks for reporting this, may I know which version of react-i13n and chrome that you are using?

@lalau is this still an issue?

lalau commented

No