Skip to content

Commit da4c7c6

Browse files
authored
fix Subscribe running in react18 StrictMode (#249)
1 parent fb7004a commit da4c7c6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/core/src/Subscribe.test.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { render } from "@testing-library/react"
2-
import React, { useState } from "react"
2+
import React, { StrictMode, useState } from "react"
33
import { defer, Observable, of } from "rxjs"
4-
import { bind, Subscribe } from "./"
4+
import { bind, Subscribe as OriginalSubscribe } from "./"
5+
6+
const Subscribe = (props: any) => {
7+
return (
8+
<StrictMode>
9+
<OriginalSubscribe {...props} />
10+
</StrictMode>
11+
)
12+
}
513

614
describe("Subscribe", () => {
715
describe("Subscribe with source$", () => {

packages/core/src/Subscribe.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const Subscribe: React.FC<{
7777
useEffect(() => {
7878
return () => {
7979
subscriptionRef.current!.unsubscribe()
80+
subscriptionRef.current = undefined
8081
}
8182
}, [])
8283

0 commit comments

Comments
 (0)