npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mobservable-react

v2.1.5

Published

React bindings for mobservable. Create fully reactive components.

Downloads

153

Readme

mobservable-react

Build Status Join the chat at https://gitter.im/mweststrate/mobservable #mobservable channel on reactiflux discord

Package with react component wrapper for combining React with mobservable. Exports the observer decorator and some development utilities. For documentation, see the mobservable project. This package supports both React and React-Native.

Installation

npm install mobservable-react --save

import {observer} from 'mobservable-react';
// - or -
import {observer} from 'mobservable-react/native';

This package provides the bindings for Mobservable and React. See the official documentation for how to get started.

Boilerplate projects that use mobservable-react

API documentation

observer(componentClass)

Function (and decorator) that converts a React component definition, React component class or stand-alone render function into a reactive component. See the mobservable documentation for more details.

reactive function

trackComponents()

Enables the tracking from components. Each rendered reactive component will be added to the componentByNodeRegistery and its renderings will be reported through the renderReporter event emitter.

renderReporter

Event emitter that reports render timings and component destructions. Only available after invoking trackComponents(). New listeners can be added through renderReporter.on(function(data) { /* */ }).

Data will have one of the following formats:

{
    event: 'render',
    renderTime: /* time spend in the .render function of a component, in ms. */,
    totalTime: /* time between starting a .render and flushing the changes to the DOM, in ms. */,
    component: /* component instance */,
    node: /* DOM node */
}
{
    event: 'destroy',
    component: /* component instance */,
    node: /* DOM Node */
}

componentByNodeRegistery

WeakMap. It's get function returns the associated reactive component of the given node. The node needs to be precisely the root node of the component. This map is only available after invoking trackComponents.

Changelog

2.1.5

Improved typescript typings overloads of observer

2.1.4

Added empty 'dependencies' section to package.json, fixes #26

2.1.3

Added support for context to stateless components. (by Kosta-Github).

2.1.1

Fixed #12: fixed React warning when a component was unmounted after scheduling a re-render but before executing it.

2.1.0

Upped dependency of mobservable to 1.1.1.

2.0.1

It is now possible to define propTypes and getDefaultProps on a stateless component:

const myComponent = (props) => {
    // render
};

myComponent.propTypes = {
    name: React.PropTypes.string
};

myComponent.defaultProps = {
    name: "World"
};

export default observer(myComponent);

All credits to Jiri Spac for this contribution!

2.0.0

Use React 0.14 instead of React 0.13. For React 0.13, use version [email protected] or higher.

1.0.2

Minor fixes and improvements

1.0.1

Fixed issue with typescript typings. An example project with Mobservable, React, Typescript, TSX can be found here: https://github.com/mweststrate/mobservable-react-typescript

1.0.0

reactiveComponent has been renamed to observer

0.2.3

Added separte import for react-native: use var reactiveComponent = require('mobservable-react/native').reactiveComponent for native support; webpack clients will refuse to build otherwise.

0.2.2

Added react-native as dependency, so that the package works with either react or react-native.

0.2.0

Upgraded to Mobservable 0.7.0

0.1.7

Fixed issue where Babel generated component classes where not properly picked up.

0.1.6

observer now accepts a pure render function as argument, besides constructor function. For example:

var TodoItem = observer(function TodoItem(props) {
    var todo = props.todo;
    return <li>{todo.task}</li>;
});

0.1.5

observer is now defined in terms of side effects.

0.1.4

Added support for React 0.14(RC) by dropping peer dependency