Skip to content

Commit

Permalink
Fixes serious performance regression String props
Browse files Browse the repository at this point in the history
6.9 introduced code that would parse the props into a Hash
unnecesarily. Any customers with significant String props took a huge
performance hit from this on page rendering.

Fix is to remove the unnecessary parsing.

I believe the parsing was done so that pretty printing of the JSON could
be done. If we introduce that feature in the future, it will:

* Be configurable on whether or not to use it.
* Possibly never run in production.
  • Loading branch information
justin808 committed Apr 24, 2017
1 parent f65fd72 commit 88d290e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/react_on_rails/react_component/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def initialize(name: required("name"), options: required("options"))
end

def props
props = options.fetch(:props) { NO_PROPS }
props.is_a?(String) ? JSON.parse(ERB::Util.json_escape(props)) : props
options.fetch(:props) { NO_PROPS }
end

def name
Expand Down

0 comments on commit 88d290e

Please sign in to comment.