ampersand-react-adapter

1.0.0 • Public • Published

ampersand-react-adapter

Higher order component for react classes to easily listen for changes and re-render from ampersand models/collections.

How it works

This auto-listens to any ampersand model or collection that is passed to it as a prop. And re-renders the component on changes. It also unregisters the listener when the component is unmounted.

You can also optionally create a method in your component called: getObservedItems.

This will get called to determine which things should be watched.

Or you can explicitly call watch on the component and pass an ampersand model, state, or collection object.

If it's a collection, it listens to 'add remove reset sort' events. If it's a State object, it listens to 'change' events.

install

npm install ampersand-react-adapter

example

import React from 'react';
import ampersandReactAdapter from 'ampersand-react-adapter';

class ExampleComponent extends React.Component{
	render() {
		return (
			<div></div>
		);
	}
}

export default ampersandReactAdapter(ExampleComponent);

license

MIT

NOTE

This is an effort to take the original ampersand-react-mixin library and port it to React Higher-Order Component

Readme

Keywords

Package Sidebar

Install

npm i ampersand-react-adapter

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

45.2 kB

Total Files

11

Last publish

Collaborators

  • ishan1608