Skip to content

Releases: acdlite/react-rx-component

Higher-order components

26 Aug 20:55
Compare
Choose a tag to compare

Previously, if the render param of createRxComponent() was omitted, the resulting component would use the child-as-function pattern:

<RxComponent>
  {props => <ChildComponent {...props} />}
</RxComponent>

This version removes that feature. In its place, the second parameter of createRxComponent() can be either a render function or a React component class.

// Same as above example
const RxComponent = createRxComponent(mapProps, ChildComponent);

Additionally, createRxComponent() is now curried. This means you can remove the second parameter entirely, and instead of a normal React component, it will create a higher-order component:

const higherOrderComponent = createRxComponent(mapProps);

class MyComponent extends React.Component {...}

export default higherOrderComponent(MyComponent);

You can also use it as a decorator:

@createRxComponent(mapProps)
export default class MyComponent extends React.Component {...}

Remove extra subscription

10 Jul 00:20
Compare
Choose a tag to compare

This release removes a hack we were using to set the initial state inside the constructor. Previously, we were creating an extra subscription and immediately disposing it as a way of "unwrapping" the initial value. Instead, now we have a check inside the observer which either calls setState() or assigns to this.state depending on whether the component has mounted.