Prevent ReactComponent to serialize Props twice on one http request. #226

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@sfadeev
sfadeev commented Feb 15, 2016

Small performance improvement to prevent ReactComponent to serialize Props twice on one http request:

  • first time on @Html.React call
  • second time on @Html.ReactInitJavaScript call
@Daniel15
Member

The issue with this approach is that Props is not immutable. In theory it could be changed between the Html.React and Html.ReactInitJavaScript calls. Even though that's pretty silly, someone may be doing it in their code. I think instead, Props should have a custom setter that also sets the serialized props.

@Daniel15 Daniel15 added a commit that closed this pull request Apr 18, 2016
@Daniel15 Daniel15 Serialize props when they're set rather than every time the component…
… render code is called. Closes #226

This ensures that the props are only serialized once, rather than twice (once in the `Html.React` call and once in the `Html.ReactInitJavaScript` call)
cdaf737
@Daniel15 Daniel15 closed this in cdaf737 Apr 18, 2016
@Daniel15
Member

I used an alternate approach in cdaf737 (serialize the props in the setter rather than in GetComponentInitialiser. Thanks for the pull request though, it was a good inspiration :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment