@@ -42,23 +42,24 @@ function shallowClone(obj) {
42
42
function renameStyle ( agent , id , oldName , newName , val ) {
43
43
var data = agent . elementData . get ( id ) ;
44
44
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 } ) ;
56
48
} 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>
58
60
}
59
61
return ;
60
62
}
61
- // </hack>
62
63
var style = data && data . props && data . props . style ;
63
64
var customStyle ;
64
65
if ( Array . isArray ( style ) ) {
@@ -91,23 +92,24 @@ function renameStyle(agent, id, oldName, newName, val) {
91
92
function setStyle ( agent , id , attr , val ) {
92
93
var data = agent . elementData . get ( id ) ;
93
94
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 } ) ;
105
98
} 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>
107
110
}
108
111
return ;
109
112
}
110
- // </hack>
111
113
var style = data . props && data . props . style ;
112
114
if ( Array . isArray ( style ) ) {
113
115
if ( typeof style [ style . length - 1 ] === 'object' && ! Array . isArray ( style [ style . length - 1 ] ) ) {
0 commit comments