Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
style
property of Ink nodes contains the changed fields ofstyle
object, rather than a fullstyle
object itself. As a result,style
in internal representation of an Ink node is inconsistent what's actually passed via astyle
prop toink-box
(rendered byBox
) orink-text
(rendered byText
).Here's example code demonstrating the problem:
borderStyle
hasn't been changed between renders, so it's no longer present in the internalstyle
object. This led to #345, which actually didn't have a proper solution to the root problem (style
being out of sync), but rather a workaround that special-cased props likeborderStyle
to always be present in thestyle
object.Solution
This PR does several things to remove this workaround I shipped before:
setStyle
function responsible for only setting styles and not updating Yoga node.prepareUpdate
to diffprops
andprops.style
prop separately.props
orprops.style
hasn't changed. It's actually unrelated to this PR, but still a nice improvement.setStyle
function.With this update,
style
is always consistent between an internal representation of an Ink node and what's passed viastyle
prop to a React component. At the same time, reconciler still updates Yoga node with styles that were changed since last render.