acdlite / acdlite/react-rx-component

"setState" on componentDidMount

Open
#4 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
83
Forks
4
PR merge metrics
No merged PRs in 30d

Description

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}



)
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.