Skip to content

Commit 6a565aa

Browse files
fix(overmind-react): fix old HOC usage without Overmind
1 parent 7a3a474 commit 6a565aa

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

packages/node_modules/overmind-react/src/__snapshots__/index.test.tsx.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`React should allow using component as normal, even when not connected 1`] = `
4+
<h1>
5+
bar
6+
</h1>
7+
`;
8+
9+
exports[`React should allow using component as normal, even when not connected 2`] = `
10+
<h1>
11+
nada
12+
</h1>
13+
`;
14+
315
exports[`React should allow using component as normal, event when connected 1`] = `
416
<h1>
517
bar

packages/node_modules/overmind-react/src/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('React', () => {
8989
expect(tree).toMatchSnapshot()
9090
})
9191

92-
test('should allow using component as normal, event when connected', () => {
92+
test('should allow using component as normal, even when not connected', () => {
9393
expect.assertions(2)
9494
const config = {
9595
state: {

packages/node_modules/overmind-react/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,14 @@ export const createConnect = <A extends Overmind<Configuration>>(
162162
if (isClassComponent) {
163163
const originalRender = component.prototype.render
164164
component.prototype.render = function() {
165-
return this.props.overmind.tree.trackScope(
166-
() => originalRender.call(this),
167-
this.props.overmind.onUpdate
168-
)
165+
if (this.props.overmind) {
166+
return this.props.overmind.tree.trackScope(
167+
() => originalRender.call(this),
168+
this.props.overmind.onUpdate
169+
)
170+
}
171+
172+
return originalRender.call(this)
169173
}
170174
}
171175

0 commit comments

Comments
 (0)