Skip to content

Commit 476bae6

Browse files
committed
Namespace react properties
1 parent 2412b61 commit 476bae6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

components/react/react.brs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
sub init()
2-
m.components = {}
3-
m.props = {}
4-
m.state = {}
5-
m.virtualTree = {}
2+
m.reactComponents = {}
3+
m.reactProps = {}
4+
m.reactState = {}
5+
m.reactVirtualTree = {}
66

77
m.top.observeField("itemContent", "reactComponentOnChangeItemContent")
88
m.top.observeField("props", "reactComponentOnChangeProps")
@@ -41,16 +41,16 @@ end sub
4141

4242
sub mapFieldsToProps(props = [] as object)
4343
for each prop in props
44-
m.props[prop] = m.top[prop]
44+
m.reactProps[prop] = m.top[prop]
4545
m.top.observeField(prop, "reactComponentOnChangeField")
4646
end for
4747
end sub
4848

4949
sub setState(state = {} as object)
50-
prevState = m.state
51-
m.state = reactSetData(m.state, state)
50+
prevState = m.reactState
51+
m.reactState = reactSetData(m.reactState, state)
5252
reactRender()
53-
componentDidUpdate(m.props, prevState)
53+
componentDidUpdate(m.reactProps, prevState)
5454
end sub
5555

5656
' Internal
@@ -81,13 +81,13 @@ function reactGetComponent(componentID = "" as string) as dynamic
8181
component = invalid
8282
if componentID = "top"
8383
component = m.top
84-
else if m.components[componentID] <> invalid
85-
component = m.components[componentID]
84+
else if m.reactComponents[componentID] <> invalid
85+
component = m.reactComponents[componentID]
8686
else
8787
component = m.top.findNode(componentID)
8888
end if
8989
' Cache component
90-
if component <> invalid then m.components[componentID] = component
90+
if component <> invalid then m.reactComponents[componentID] = component
9191
return component
9292
end function
9393

@@ -97,7 +97,7 @@ sub reactRender()
9797
' Rendered exclusively by side effect
9898
return
9999
end if
100-
m.virtualTree = virtualTree
100+
m.reactVirtualTree = virtualTree
101101
for each componentID in virtualTree
102102
componentProps = virtualTree[componentID]
103103
component = reactGetComponent(componentID)
@@ -129,11 +129,11 @@ function reactSetData(prevData = {} as object, data = invalid as dynamic)
129129
end function
130130

131131
sub reactSetProps(props = {} as object)
132-
nextProps = reactSetData(m.props, props)
133-
prevProps = m.props
134-
m.props = nextProps
132+
nextProps = reactSetData(m.reactProps, props)
133+
prevProps = m.reactProps
134+
m.reactProps = nextProps
135135
if shouldComponentUpdate(nextProps)
136136
reactRender()
137-
componentDidUpdate(prevProps, m.state)
137+
componentDidUpdate(prevProps, m.reactState)
138138
end if
139139
end sub

0 commit comments

Comments
 (0)