acdlite / acdlite/react-rx-component

"setState" on componentDidMount

オープン
#4 コメント 7 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。