Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit f3a86f7

Browse files
committed
fix should_component_update?
1 parent 8303c87 commit f3a86f7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/react/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class extends React.Component {
7373
}
7474
shouldComponentUpdate(next_props, next_state) {
7575
var instance = this._getOpalInstance.apply(this);
76-
return #{`instance`.should_component_update?(Hash.new(`next_props`), Hash.new(`next_state`)) if type.method_defined? :should_component_update?};
76+
return #{`instance`.should_component_update?(`Opal.hash(next_props !== null ? next_props : {})`, `Opal.hash(next_state !== null ? next_state : {})`) if type.method_defined? :should_component_update?};
7777
}
7878
componentWillUpdate(next_props, next_state) {
7979
var instance = this._getOpalInstance.apply(this);

lib/react/component/should_component_update.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Component
2525
module ShouldComponentUpdate
2626
def should_component_update?(native_next_props, native_next_state)
2727
State.set_state_context_to(self, false) do
28-
next_params = Hash.new(native_next_props)
28+
next_params = native_next_props.clone
2929
# rubocop:disable Style/DoubleNegation # we must return true/false to js land
3030
if respond_to?(:needs_update?)
3131
!!call_needs_update(next_params, native_next_state)
@@ -65,6 +65,7 @@ def call_needs_update(next_params, native_next_state)
6565

6666
# rubocop:disable Metrics/MethodLength # for effeciency we want this to be one method
6767
def native_state_changed?(next_state)
68+
next_state = next_state_hash.to_n
6869
%x{
6970
var current_state = #{@native}.state
7071
var normalized_next_state =

0 commit comments

Comments
 (0)