From d70b50bfa7019f3b76a11556727ef8d58a37c4af Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Tue, 15 May 2018 14:36:41 -0700 Subject: [PATCH] Hoist makeStateUpdater into top of scope --- lib/connect2.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/connect2.lua b/lib/connect2.lua index a993a97..67e1364 100644 --- a/lib/connect2.lua +++ b/lib/connect2.lua @@ -14,6 +14,21 @@ local function noop() return nil end +local function makeStateUpdater(store, mapStateToProps) + return function(nextProps, prevState, mappedStoreState) + if mappedStoreState == nil then + mappedStoreState = mapStateToProps(store:getState(), nextProps) + end + + local propsForChild = join(nextProps, mappedStoreState, prevState.mappedStoreDispatch) + + return { + mappedStoreState = mappedStoreState, + propsForChild = propsForChild, + } + end +end + --[[ mapStateToProps: (storeState, props) -> partialProps @@ -49,21 +64,6 @@ local function connect(mapStateToPropsOrThunk, mapDispatchToProps) error(message, 2) end - local function makeStateUpdater(store, mapStateToProps) - return function(nextProps, prevState, mappedStoreState) - if mappedStoreState == nil then - mappedStoreState = mapStateToProps(store:getState(), nextProps) - end - - local propsForChild = join(nextProps, mappedStoreState, prevState.mappedStoreDispatch) - - return { - mappedStoreState = mappedStoreState, - propsForChild = propsForChild, - } - end - end - local componentName = ("RoduxConnection(%s)"):format(tostring(innerComponent)) local outerComponent = Roact.Component:extend(componentName)