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 摘要。