Skip to content

Commit 0edd1ca

Browse files
committed
docs: reformat readme codes
1 parent 77c62d4 commit 0edd1ca

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

README.md

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,6 @@ function App() {
3333
ReactDOM.render(<App />, document.querySelector('#app'))
3434
```
3535

36-
#### Simple:
37-
```tsx
38-
import React from 'react'
39-
import ReactDOM from 'react-dom'
40-
import { useObservable } from 'rxjs-hooks'
41-
import { of } from 'rxjs'
42-
43-
function App() {
44-
const value = useObservable(() => of(1000))
45-
return (
46-
// render twice
47-
// null and 1000
48-
<h1>{value}</h1>
49-
)
50-
}
51-
52-
ReactDOM.render(<App />, document.querySelector('#app'))
53-
```
54-
5536
#### With default value:
5637
```tsx
5738
import React from 'react'
@@ -125,9 +106,11 @@ import { useEventCallback } from 'rxjs-hooks'
125106
import { mapTo } from 'rxjs/operators'
126107
127108
function App() {
128-
const [clickCallback, value] = useEventCallback((event$: Observable<React.React.SyntheticEvent<HTMLButtonElement>>) => event$.pipe(
129-
mapTo(1000)
130-
))
109+
const [clickCallback, value] = useEventCallback((event$: Observable<React.React.SyntheticEvent<HTMLButtonElement>>) =>
110+
event$.pipe(
111+
mapTo(1000)
112+
)
113+
)
131114
return (
132115
// render null
133116
// click button
@@ -151,9 +134,12 @@ import { useEventCallback } from 'rxjs-hooks'
151134
import { mapTo } from 'rxjs/operators'
152135
153136
function App() {
154-
const [clickCallback, value] = useEventCallback((event$: Observable<React.React.SyntheticEvent<HTMLButtonElement>>) => event$.pipe(
155-
mapTo(1000)
156-
), 200)
137+
const [clickCallback, value] = useEventCallback((event$: Observable<React.React.SyntheticEvent<HTMLButtonElement>>) =>
138+
event$.pipe(
139+
mapTo(1000)
140+
),
141+
200,
142+
)
157143
return (
158144
// render 200
159145
// click button

0 commit comments

Comments
 (0)