diff --git a/src/hoc/stateParamsObserver.spec.tsx b/src/hoc/stateParamsObserver.spec.tsx
index 9796a74..a3e1bfb 100644
--- a/src/hoc/stateParamsObserver.spec.tsx
+++ b/src/hoc/stateParamsObserver.spec.tsx
@@ -18,7 +18,7 @@ router.stateRegistry.register({
})
const updateCountedComponent = () => {
- const self = React.StatelessComponent = () => {
+ const self = React.StatelessComponent = (props: { color: string }) => {
self.updates += 1;
return (
);
};
@@ -33,7 +33,7 @@ it('maps state param changes to props', async () => {
const innerComponent = updateCountedComponent();
const WrappedComponent = stateParamsObserver(innerComponent);
- const component = mount(, { context: { router } });
+ const component = mount(, { context: { router } });
const inner = component.find('InnerComponent');
await router.stateService.go('test', { page: 1 });
@@ -41,7 +41,8 @@ it('maps state param changes to props', async () => {
'#': null,
page: 1,
search: null,
- showDeleted: null
+ showDeleted: null,
+ color: 'red'
});
await router.stateService.go('test', { page: 2, showDeleted: true });
@@ -49,7 +50,8 @@ it('maps state param changes to props', async () => {
'#': null,
page: 2,
search: null,
- showDeleted: true
+ showDeleted: true,
+ color: 'red'
});
component.unmount();
@@ -123,6 +125,23 @@ it('maps props to wrapped component on mount', async () => {
});
});
+it('passes through changes to non-observed props', async () => {
+ const innerComponent = updateCountedComponent();
+ const WrappedComponent = stateParamsObserver(innerComponent);
+ const component = mount(, { context: { router } });
+
+ component.setProps({ color: 'blue' });
+
+ const props = component.find('InnerComponent').props();
+ expect(props).toEqual({
+ '#': null,
+ page: 3,
+ search: 'widgets',
+ showDeleted: true,
+ color: 'blue'
+ });
+});
+
it('throws an error if @ui-router/rx is not installed', () => {
const innerComponent = updateCountedComponent();
const WrappedComponent = stateParamsObserver(innerComponent);
diff --git a/src/hoc/stateParamsObserver.tsx b/src/hoc/stateParamsObserver.tsx
index c8eabf4..0fb80e4 100644
--- a/src/hoc/stateParamsObserver.tsx
+++ b/src/hoc/stateParamsObserver.tsx
@@ -49,8 +49,8 @@ export const stateParamsObserver =
render() {
return (
);