JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q27492F
  • License MIT

Lightweight React bindings for lobx based on React 16.8+ and Hooks

Package Exports

  • lobx-react
  • lobx-react/dist/index.js
  • lobx-react/dist/lobxreact.esm.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lobx-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lobx-react

You need React version 16.8.0 and above

API reference ⚒

observer<P>(baseComponent: Component<P>, options?: ObserverOptions): Component<P>

interface ObserverOptions {
    // Pass true to wrap the inner component with React.forwardRef.
    // It's false by the default.
    forwardRef?: boolean
    graph?: Graph
}

The observer converts a component into a reactive component, which tracks which observables are used automatically and re-renders the component when one of these values changes.

useObservable<T>(sourceOrInitializer: T | (() => T)): T

The useObservable hook can be used to turn any set of values into an observable object that has a stable reference (the same object is returned every time from the hook). You can either pass in a default value or a initializer function that will run once and the value returned will be the default.

<Observer>{renderFn}</Observer>

Is a React component, which applies observer to an anonymous region in your component.

enableStaticRendering(enable: true)

Call enableStaticRendering(true) when running in an SSR environment, in which observer wrapped components should never re-render, but cleanup after the first rendering automatically. Use isUsingStaticRendering() to inspect the current setting.