react-lottie 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.3.1](https://github.com/chenqingspring/react-lottie/compare/v2.3.0...v2.3.1) (2026-11-05)
6
+
7
+ ### Bug Fixes
8
+
9
+ * tolerate a missing or non-array `eventListeners` prop instead of throwing `eventListeners.forEach is not a function` on mount and unmount, which could break animations rendered through `React.lazy` ([#137](https://github.com/chenqingspring/react-lottie/issues/137))
10
+
5
11
  ## [2.3.0](https://github.com/chenqingspring/react-lottie/compare/v2.2.0...v2.3.0) (2026-11-05)
6
12
 
7
13
  ### Features
package/dist/index.js CHANGED
@@ -248,6 +248,11 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
248
248
  key: "registerEvents",
249
249
  value: function registerEvents(eventListeners) {
250
250
  var _this2 = this;
251
+ /* `eventListeners` is array-valued and defaults to `[]`, but a wrapper
252
+ component (React.lazy, an HOC, a prop spread with `null`) can hand us
253
+ something else. Treat anything that is not an array as "no listeners";
254
+ blindly calling forEach used to crash on mount and unmount (#137). */
255
+ if (!this.anim || !Array.isArray(eventListeners)) return;
251
256
  eventListeners.forEach(function (eventListener) {
252
257
  _this2.anim.addEventListener(eventListener.eventName, eventListener.callback);
253
258
  });
@@ -256,6 +261,7 @@ var Lottie = exports["default"] = /*#__PURE__*/function (_React$Component) {
256
261
  key: "deRegisterEvents",
257
262
  value: function deRegisterEvents(eventListeners) {
258
263
  var _this3 = this;
264
+ if (!this.anim || !Array.isArray(eventListeners)) return;
259
265
  eventListeners.forEach(function (eventListener) {
260
266
  _this3.anim.removeEventListener(eventListener.eventName, eventListener.callback);
261
267
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-lottie",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "funding": "https://opencollective.com/react-lottie",
5
5
  "description": "lottie animation view for React",
6
6
  "repository": {