zl程序教程

您现在的位置是:首页 >  前端

当前栏目

[Recompose] Configure Recompose to Build React Components from RxJS Streams

React to from build Rxjs Components configure Streams
2023-09-14 09:00:51 时间

Recompose provides helper functions to stream props using an Observable library of your choice into React. This lesson shows you how to configure Recompose to use RxJS then create a Streaming Component with Recompose’s componentFromStream helper function.

 

import React from "react"
import { render } from "react-dom"
import { Observable } from "rxjs"
import config from "recompose/rxjsObservableConfig"
import {
  setObservableConfig,
  componentFromStream
} from "recompose"

setObservableConfig(config)

/*
APP Start
*/

const App = componentFromStream(props$ => props$.map(props => <h1>{props.message}</h1>))

render(<App message="Hello World!" />, document.getElementById("root"))