-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 26 update to new context api (#38)
This fix Closes #26 Issue: StoreProvider and Connect used the legacy context API, this change updates it to the new API Fix: Added a file StoreContext.lua that returns a static Roact Context. StoreProvider now returns a Roact Provider that passes a Rodux Store as its "value". Connect now uses a Roact Consumer to read in the store via props.
- Loading branch information
Showing
9 changed files
with
31 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ content_root = "src" | |
version = "0.2.3" | ||
|
||
[dependencies] | ||
Roact = "github.com/roblox/roact@1.2" | ||
Roact = "github.com/roblox/roact@1.3" | ||
Rodux = "github.com/roblox/[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local Roact = require(script.Parent.Parent.Roact) | ||
|
||
local StoreContext = Roact.createContext() | ||
|
||
return StoreContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
local Roact = require(script.Parent.Parent.Roact) | ||
|
||
local storeKey = require(script.Parent.storeKey) | ||
local StoreContext = require(script.Parent.StoreContext) | ||
|
||
local StoreProvider = Roact.Component:extend("StoreProvider") | ||
|
||
function StoreProvider:init(props) | ||
local store = props.store | ||
|
||
if store == nil then | ||
error("Error initializing StoreProvider. Expected a `store` prop to be a Rodux store.") | ||
end | ||
|
||
self._context[storeKey] = store | ||
self.store = store | ||
end | ||
|
||
function StoreProvider:render() | ||
return Roact.createFragment(self.props[Roact.Children]) | ||
return Roact.createElement(StoreContext.Provider, { | ||
value = self.store | ||
}, self.props[Roact.Children]) | ||
end | ||
|
||
return StoreProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
local StoreProvider = require(script.StoreProvider) | ||
local connect = require(script.connect) | ||
local getStore = require(script.getStore) | ||
|
||
return { | ||
StoreProvider = StoreProvider, | ||
connect = connect, | ||
UNSTABLE_getStore = getStore, | ||
UNSTABLE_connect2 = connect, | ||
} |
This file was deleted.
Oops, something went wrong.