This document focuses on React, but the same applies to Inferno and Preact
Background
Refract builds upon two ideas which have been embraced by the React community: separating presentational and container components, plus higher-order components (HoCs).
The key insight behind presentational/container components is that your application's state and its view should be separated. In React, your state is typically passed into your view as props.
Refract sits between your state and your view, allowing you to observe the changes to those props over time. To achieve this, you simply wrap your view with Refract's withEffects higher-order component.
If we want to cause side-effects in response to changes in the props being passed into our Counter, we use withEffects to create an enhanced version of the component:
import { withEffects } from'refract-rxjs'// Note that the handler and aperture are explained later in the docs,// these empty functions are just placeholdersconstaperture= (component, initialProps) => {}consthandler= initialProps => effect => {}//constCounterWithEffects=withEffects(aperture, { handler })(Counter)
This new CounterWithEffects component now includes the side-effect logic included in our handler and aperture, and renders the original Counter presentational component unaltered. It can be used just like any other component: