Registry / ai-ml / react-image-annotation

react-image-annotation

JSON →
library0.9.10jsnpmunverified

A React library for adding annotations to images. Current stable version is 0.9.10 (last updated 2019). Release cadence is low; no active development since 2020. Supports customizable selectors (rectangle, point, oval) and full rendering control via render props. Key differentiator: provides both annotation creation (geometry) and metadata storage (data) with custom component slots. Requires React 16.3+ and prop-types. Alternative for newer versions or ESM-only environments may need to consider forks.

npm install react-image-annotation
INSTALL
IMPORT
SIG · REACT-IMAGE-ANNOTA
R
react-image-annotation
ai-mljavascriptv0.9.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Annotation
import Annotation from 'react-image-annotation'
import { Annotation } from 'react-image-annotation'
Default export only; named import will be undefined.
default import
import Annotation from 'react-image-annotation'
const Annotation = require('react-image-annotation')
ESM import is correct; CommonJS require breaks default import pattern in bundlers.
RectangleSelector
import { RectangleSelector } from 'react-image-annotation/selectors'
import { RectangleSelector } from 'react-image-annotation'
Selectors are exported from subpath; not directly from main entry.

Basic usage of Annotation component with state management for annotations.

import React, { Component } from 'react'; import Annotation from 'react-image-annotation'; import { RectangleSelector } from 'react-image-annotation/selectors'; class Simple extends Component { state = { annotations: [], annotation: {} }; onChange = (annotation) => { this.setState({ annotation }); }; onSubmit = (annotation) => { const { geometry, data } = annotation; this.setState({ annotation: {}, annotations: this.state.annotations.concat({ geometry, data: { ...data, id: Math.random() } }) }); }; render() { return ( <div> <Annotation src='https://example.com/image.jpg' alt='example' annotations={this.state.annotations} type={this.state.type || 'RECTANGLE'} value={this.state.annotation} onChange={this.onChange} onSubmit={this.onSubmit} selectors={[RectangleSelector]} /> </div> ); } } export default Simple;
Debug
Known issues
deprecatedPackage has not been updated since 2019 and may contain unpatched vulnerabilities.
fix
Consider migrating to actively maintained alternative like 'react-image-annotate'.
affects: all
breakingReact 16.3+ required; will not work with React <16.3.
fix
Upgrade React to >=16.3 or use an older version of the library (<0.9.0).
affects: >=0.9.0
gotchaSelectors must be imported from 'react-image-annotation/selectors' subpath, not from main entry.
fix
Use import { RectangleSelector } from 'react-image-annotation/selectors'.
affects: >=0.9.0
Errors
Common errors & fixes
Module not found: Can't resolve 'react-image-annotation/selectors'
Typo or wrong import path for selectors.
fix
Ensure import path is exactly 'react-image-annotation/selectors'.
TypeError: Cannot read property 'type' of undefined
Missing geometry.type in annotation object.
fix
Ensure annotation geometry has a type field (e.g., 'RECTANGLE').
Warning: React does not recognize the `allowTouch` prop on a DOM element
allowTouch prop is passed to underlying DOM element instead of being consumed.
fix
Upgrade to latest version or avoid using allowTouch; it may be fixed in newer releases.
Upgrade
Version history
0.9.10latest on npm
Audit
Dependencies
prop-typesrequiredrequired peer dependency for runtime type checking
reactrequiredpeer dependency; requires React >=16.3
react-domrequiredpeer dependency; requires react-dom >=0.14
Agent activity
13 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
react-image-annotation — npm install react-image-annotation · libregistry