acdlite / acdlite/react-rx-component

"setState" on componentDidMount

Aberta
#4 7 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
83
Forks
4
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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}



)
}
```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.