@@ -42,23 +42,24 @@ function shallowClone(obj) {
4242function renameStyle ( agent , id , oldName , newName , val ) {
4343 var data = agent . elementData . get ( id ) ;
4444 var newStyle = { [ newName ] : val } ;
45- if ( ! data ) {
46- return ;
47- }
48- // <hack>
49- // We can remove this when we stop supporting RN versions
50- // before https://github.com/facebook/react-devtools/pull/528.
51- // Newer versions just use the same `updater` path for native updates.
52- if ( ! data . updater || ! data . updater . setInProps ) {
53- var el = agent . reactElements . get ( id ) ;
54- if ( el && el . setNativeProps ) {
55- el . setNativeProps ( { style : newStyle } ) ;
45+ if ( ! data || ! data . updater || ! data . updater . setInProps ) {
46+ if ( data && data . updater && data . updater . setNativeProps ) {
47+ data . updater . setNativeProps ( { style : newStyle } ) ;
5648 } else {
57- console . error ( 'Unable to set style for this element... (no forceUpdate or setNativeProps)' ) ;
49+ // <hack>
50+ // We can remove this when we stop supporting RN versions
51+ // before https://github.com/facebook/react-devtools/pull/528.
52+ // Newer versions use `updater.setNativeProps` instead.
53+ var el = agent . reactElements . get ( id ) ;
54+ if ( el && el . setNativeProps ) {
55+ el . setNativeProps ( { style : newStyle } ) ;
56+ } else {
57+ console . error ( 'Unable to set style for this element... (no forceUpdate or setNativeProps)' ) ;
58+ }
59+ // </hack>
5860 }
5961 return ;
6062 }
61- // </hack>
6263 var style = data && data . props && data . props . style ;
6364 var customStyle ;
6465 if ( Array . isArray ( style ) ) {
@@ -91,23 +92,24 @@ function renameStyle(agent, id, oldName, newName, val) {
9192function setStyle ( agent , id , attr , val ) {
9293 var data = agent . elementData . get ( id ) ;
9394 var newStyle = { [ attr ] : val } ;
94- if ( ! data ) {
95- return ;
96- }
97- // <hack>
98- // We can remove this when we stop supporting RN versions
99- // before https://github.com/facebook/react-devtools/pull/528.
100- // Newer versions just use the same `updater` path for native updates.
101- if ( ! data . updater || ! data . updater . setInProps ) {
102- var el = agent . reactElements . get ( id ) ;
103- if ( el && el . setNativeProps ) {
104- el . setNativeProps ( { style : newStyle } ) ;
95+ if ( ! data || ! data . updater || ! data . updater . setInProps ) {
96+ if ( data && data . updater && data . updater . setNativeProps ) {
97+ data . updater . setNativeProps ( { style : newStyle } ) ;
10598 } else {
106- console . error ( 'Unable to set style for this element... (no forceUpdate or setNativeProps)' ) ;
99+ // <hack>
100+ // We can remove this when we stop supporting RN versions
101+ // before https://github.com/facebook/react-devtools/pull/528.
102+ // Newer versions use `updater.setNativeProps` instead.
103+ var el = agent . reactElements . get ( id ) ;
104+ if ( el && el . setNativeProps ) {
105+ el . setNativeProps ( { style : newStyle } ) ;
106+ } else {
107+ console . error ( 'Unable to set style for this element... (no forceUpdate or setNativeProps)' ) ;
108+ }
109+ // </hack>
107110 }
108111 return ;
109112 }
110- // </hack>
111113 var style = data . props && data . props . style ;
112114 if ( Array . isArray ( style ) ) {
113115 if ( typeof style [ style . length - 1 ] === 'object' && ! Array . isArray ( style [ style . length - 1 ] ) ) {
0 commit comments