Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.

Commit 6c5b5f6

Browse files
committed
Merge branch 'fix-context-fatal-error'
2 parents 26c1f7d + 9fb4df9 commit 6c5b5f6

File tree

5 files changed

+96
-7
lines changed

5 files changed

+96
-7
lines changed

.all-contributorsrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@
7070
"code",
7171
"test"
7272
]
73+
},
74+
{
75+
"login": "macklay",
76+
"name": "Nick Smirnov",
77+
"avatar_url": "https://avatars3.githubusercontent.com/u/6972011?v=4",
78+
"profile": "https://github.com/macklay",
79+
"contributions": [
80+
"code"
81+
]
7382
}
7483
],
75-
"repoType": "github"
84+
"repoType": "github",
85+
"commitConvention": "none"
7686
}

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,21 @@ _Whats with the name?_
6666
Thanks goes to these wonderful people ([emojis](https://github.com/kentcdodds/all-contributors#emoji-key)):
6767

6868
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
69-
<!-- prettier-ignore -->
70-
| [<img src="https://avatars0.githubusercontent.com/u/23029903?v=4" width="100px;"/><br /><sub><b>Michael Peyper</b></sub>](https://github.com/mpeyper)<br />[💬](#question-mpeyper "Answering Questions") [🐛](https://github.com/ioof-holdings/@redux-dynostore/core/issues?q=author%3Ampeyper "Bug reports") [💻](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=mpeyper "Code") [📖](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=mpeyper "Documentation") [💡](#example-mpeyper "Examples") [🤔](#ideas-mpeyper "Ideas, Planning, & Feedback") [🚇](#infra-mpeyper "Infrastructure (Hosting, Build-Tools, etc)") [👀](#review-mpeyper "Reviewed Pull Requests") [📦](#platform-mpeyper "Packaging/porting to new platform") [📢](#talk-mpeyper "Talks") [⚠️](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=mpeyper "Tests") [🔧](#tool-mpeyper "Tools") | [<img src="https://avatars2.githubusercontent.com/u/6560018?v=4" width="100px;"/><br /><sub><b>Jonathan Peyper</b></sub>](https://github.com/jpeyper)<br />[💬](#question-jpeyper "Answering Questions") [🐛](https://github.com/ioof-holdings/@redux-dynostore/core/issues?q=author%3Ajpeyper "Bug reports") [💻](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=jpeyper "Code") [🤔](#ideas-jpeyper "Ideas, Planning, & Feedback") [👀](#review-jpeyper "Reviewed Pull Requests") [⚠️](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=jpeyper "Tests") | [<img src="https://avatars3.githubusercontent.com/u/11048958?v=4" width="100px;"/><br /><sub><b>Greg Miller</b></sub>](https://github.com/Gregor1971)<br />[💡](#example-Gregor1971 "Examples") | [<img src="https://avatars2.githubusercontent.com/u/1493968?v=4" width="100px;"/><br /><sub><b>Ethorsen</b></sub>](https://github.com/Ethorsen)<br />[💻](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Ethorsen "Code") [📖](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Ethorsen "Documentation") [⚠️](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Ethorsen "Tests") | [<img src="https://avatars0.githubusercontent.com/u/6849798?v=4" width="100px;"/><br /><sub><b>Jake88</b></sub>](https://github.com/Jake88)<br />[💻](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Jake88 "Code") [⚠️](https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Jake88 "Tests") |
71-
| :---: | :---: | :---: | :---: | :---: |
69+
<!-- prettier-ignore-start -->
70+
<!-- markdownlint-disable -->
71+
<table>
72+
<tr>
73+
<td align="center"><a href="https://github.com/mpeyper"><img src="https://avatars0.githubusercontent.com/u/23029903?v=4" width="100px;" alt=""/><br /><sub><b>Michael Peyper</b></sub></a><br /><a href="#question-mpeyper" title="Answering Questions">💬</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/issues?q=author%3Ampeyper" title="Bug reports">🐛</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=mpeyper" title="Code">💻</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=mpeyper" title="Documentation">📖</a> <a href="#example-mpeyper" title="Examples">💡</a> <a href="#ideas-mpeyper" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-mpeyper" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/pulls?q=is%3Apr+reviewed-by%3Ampeyper" title="Reviewed Pull Requests">👀</a> <a href="#platform-mpeyper" title="Packaging/porting to new platform">📦</a> <a href="#talk-mpeyper" title="Talks">📢</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=mpeyper" title="Tests">⚠️</a> <a href="#tool-mpeyper" title="Tools">🔧</a></td>
74+
<td align="center"><a href="https://github.com/jpeyper"><img src="https://avatars2.githubusercontent.com/u/6560018?v=4" width="100px;" alt=""/><br /><sub><b>Jonathan Peyper</b></sub></a><br /><a href="#question-jpeyper" title="Answering Questions">💬</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/issues?q=author%3Ajpeyper" title="Bug reports">🐛</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=jpeyper" title="Code">💻</a> <a href="#ideas-jpeyper" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/pulls?q=is%3Apr+reviewed-by%3Ajpeyper" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=jpeyper" title="Tests">⚠️</a></td>
75+
<td align="center"><a href="https://github.com/Gregor1971"><img src="https://avatars3.githubusercontent.com/u/11048958?v=4" width="100px;" alt=""/><br /><sub><b>Greg Miller</b></sub></a><br /><a href="#example-Gregor1971" title="Examples">💡</a></td>
76+
<td align="center"><a href="https://github.com/Ethorsen"><img src="https://avatars2.githubusercontent.com/u/1493968?v=4" width="100px;" alt=""/><br /><sub><b>Ethorsen</b></sub></a><br /><a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Ethorsen" title="Code">💻</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Ethorsen" title="Documentation">📖</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Ethorsen" title="Tests">⚠️</a></td>
77+
<td align="center"><a href="https://github.com/Jake88"><img src="https://avatars0.githubusercontent.com/u/6849798?v=4" width="100px;" alt=""/><br /><sub><b>Jake88</b></sub></a><br /><a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Jake88" title="Code">💻</a> <a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=Jake88" title="Tests">⚠️</a></td>
78+
<td align="center"><a href="https://github.com/macklay"><img src="https://avatars3.githubusercontent.com/u/6972011?v=4" width="100px;" alt=""/><br /><sub><b>Nick Smirnov</b></sub></a><br /><a href="https://github.com/ioof-holdings/@redux-dynostore/core/commits?author=macklay" title="Code">💻</a></td>
79+
</tr>
80+
</table>
81+
82+
<!-- markdownlint-enable -->
83+
<!-- prettier-ignore-end -->
7284
<!-- ALL-CONTRIBUTORS-LIST:END -->
7385

7486
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.

packages/redux-dynostore-react-redux-subspace/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ When mounted, `MyComponent` will be wrapped in a [`SubspaceProvider`](https://io
4949

5050
If you are attaching a reducer dynamically, you should use the [redux-subspace variant](/packages/redux-dynostore-redux-subspace) to ensure it will receive the namespaced actions.
5151

52-
##### `stateHandler`
52+
### `stateHandler`
5353

5454
```javascript
5555
const store = createStore(reducer, dynostore(dynamicReducers(), { stateHandler: customStateHandler }))
@@ -72,3 +72,15 @@ State handlers are provided as an object with the following functions:
7272
_Note, this is a subset of [the `stateHandler` option of `dynamicReducers`](/packages/redux-dynostore-core#stateHandler)._
7373

7474
By default, `subspaced` will use the `defaultStateHandler` exported from the core package.
75+
76+
### Additional Subspace Options
77+
78+
Any additional options provided to `subspaced` will be passed through as the [options argument to the underlying `react-redux-subspace` library](https://ioof-holdings.github.io/redux-subspace/packages/react-redux-subspace/docs/api/subspaced.html#arguments). This is most commonly used to provide a custom context to locate the Redux store to use:
79+
80+
```javascript
81+
const CustomContext = React.createContext
82+
83+
// ...
84+
85+
export default dynamic('identifier', subspaced({ context: CustomContext }))(MyComponent)
86+
```

packages/redux-dynostore-react-redux-subspace/src/subspaced.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
import { subspaced } from 'react-redux-subspace'
1010
import { defaultStateHandler } from '@redux-dynostore/core'
1111

12-
const subspacedEnhancer = ({ stateHandler, mapExtraState = () => null } = {}) => identifier => store => {
12+
const subspacedEnhancer = ({
13+
stateHandler,
14+
mapExtraState = () => null,
15+
...subspaceOptions
16+
} = {}) => identifier => store => {
1317
const defaultOptions = store.dynostoreOptions || {}
1418
const { getValue, canMerge, merge } = stateHandler || defaultOptions.stateHandler || defaultStateHandler
1519

@@ -29,7 +33,7 @@ const subspacedEnhancer = ({ stateHandler, mapExtraState = () => null } = {}) =>
2933

3034
return merge(extraState, componentState)
3135
}
32-
const subspaceEnhancer = subspaced(mapState, identifier)
36+
const subspaceEnhancer = subspaced(mapState, identifier, subspaceOptions)
3337
return Component => subspaceEnhancer(Component)
3438
}
3539

packages/redux-dynostore-react-redux-subspace/test/subspaced.test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,54 @@ describe('mapExtraState tests', () => {
276276
).toThrow(TypeError)
277277
})
278278
})
279+
280+
describe('subspaceOptions tests', () => {
281+
const mockStore = configureStore([])
282+
let store
283+
284+
const CustomContext = React.createContext()
285+
286+
class TestComponent extends React.Component {
287+
render() {
288+
return <p>{this.props.testKey}</p>
289+
}
290+
}
291+
292+
const mapStateToProps = state => ({
293+
testKey: state.testKey
294+
})
295+
296+
const ConnectedTestComponent = connect(
297+
mapStateToProps,
298+
null,
299+
null,
300+
{ context: CustomContext }
301+
)(TestComponent)
302+
303+
beforeEach(() => {
304+
store = mockStore({
305+
testId: {
306+
testKey: 'root value'
307+
},
308+
parentId: {
309+
testId: {
310+
testKey: 'nested value'
311+
}
312+
}
313+
})
314+
})
315+
316+
test('should create subspaced enhanced component using custom context', () => {
317+
const SubspacedComponent = subspaced({ context: CustomContext })('testId')(store)(ConnectedTestComponent)
318+
319+
const { getByText } = render(
320+
<Provider store={store} context={CustomContext}>
321+
<SubspaceProvider mapState={state => state.parentId} namespace="parentId" context={CustomContext}>
322+
<SubspacedComponent />
323+
</SubspaceProvider>
324+
</Provider>
325+
)
326+
327+
expect(getByText('nested value')).toBeDefined()
328+
})
329+
})

0 commit comments

Comments
 (0)