acdlite / acdlite/react-rx-component

"setState" on componentDidMount

未關閉
#4 7 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
83
分支
4
PR 合併指標
30 天內沒有已合併 PR

描述

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}



)
}
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。