acdlite / acdlite/react-rx-component
"setState" on componentDidMount
- Vorherrschende Sprache
- JavaScript
- Sterne
- 83
- Forks
- 4
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hi
I'm trying to create a smart component to retrieve window size and pass it as props to the dumb component. It works fine when I resize the window.
I was wondering how i could update width and height on componentDidMount with this approach.
``` javascript
const TestContainer = createRxComponent(props$ => {
const resize$ = Observable
.fromEvent(window, 'resize')
.map( e => ({ width: window.innerWidth, height: window.innerHeight }) )
.startWith({ width: 0, height: 0 })
return Observable.combineLatest(props$, resize$, (props, { width, height }) => ({
...props,
width,
height
}))
}, Test)
function Test(props){
const { width, height } = props
return (
width: {width}
height: {height}
)
}
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.