@react-three/fiber 8.2.0 → 8.2.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
@@ -1,5 +1,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 25e35a1: fix: prefer useLayoutEffect in react-native
8
+
3
9
  ## 8.2.0
4
10
 
5
11
  ### Minor Changes
@@ -4,7 +4,7 @@ import { AttachType, Instance, InstanceProps, LocalState } from './renderer';
4
4
  import { Dpr, RootState, Size } from './store';
5
5
  export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
6
6
  export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
7
- export declare const useIsomorphicLayoutEffect: typeof React.useEffect;
7
+ export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
8
8
  export declare function useMutableCallback<T>(fn: T): React.MutableRefObject<T>;
9
9
  export declare type SetBlock = false | Promise<null> | null;
10
10
  export declare type UnblockProps = {
@@ -10,12 +10,19 @@ var threeTypes = /*#__PURE__*/Object.freeze({
10
10
  __proto__: null
11
11
  });
12
12
 
13
- const isOrthographicCamera = def => def && def.isOrthographicCamera; // React currently throws a warning when using useLayoutEffect on the server.
14
- // To get around it, we can conditionally useEffect on the server (no-op) and
15
- // useLayoutEffect on the client.
13
+ var _window$document, _window$navigator;
14
+ const isOrthographicCamera = def => def && def.isOrthographicCamera;
15
+ /**
16
+ * An SSR-friendly useLayoutEffect.
17
+ *
18
+ * React currently throws a warning when using useLayoutEffect on the server.
19
+ * To get around it, we can conditionally useEffect on the server (no-op) and
20
+ * useLayoutEffect elsewhere.
21
+ *
22
+ * @see https://github.com/facebook/react/issues/14927
23
+ */
16
24
 
17
- const isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
18
- const useIsomorphicLayoutEffect = isSSR ? React.useEffect : React.useLayoutEffect;
25
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React.useLayoutEffect : React.useEffect;
19
26
  function useMutableCallback(fn) {
20
27
  const ref = React.useRef(fn);
21
28
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
@@ -1149,10 +1156,10 @@ function createRenderer(_roots, _getEventPriority) {
1149
1156
  },
1150
1157
 
1151
1158
  createTextInstance: () => {
1152
- throw new Error('Text is not allowed in the R3F tree.');
1159
+ throw new Error('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
1153
1160
  },
1154
1161
  hideTextInstance: () => {
1155
- throw new Error('Text is not allowed in the R3F tree.');
1162
+ throw new Error('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
1156
1163
  },
1157
1164
  unhideTextInstance: () => {},
1158
1165
  // https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
@@ -37,12 +37,19 @@ var threeTypes = /*#__PURE__*/Object.freeze({
37
37
  __proto__: null
38
38
  });
39
39
 
40
- const isOrthographicCamera = def => def && def.isOrthographicCamera; // React currently throws a warning when using useLayoutEffect on the server.
41
- // To get around it, we can conditionally useEffect on the server (no-op) and
42
- // useLayoutEffect on the client.
40
+ var _window$document, _window$navigator;
41
+ const isOrthographicCamera = def => def && def.isOrthographicCamera;
42
+ /**
43
+ * An SSR-friendly useLayoutEffect.
44
+ *
45
+ * React currently throws a warning when using useLayoutEffect on the server.
46
+ * To get around it, we can conditionally useEffect on the server (no-op) and
47
+ * useLayoutEffect elsewhere.
48
+ *
49
+ * @see https://github.com/facebook/react/issues/14927
50
+ */
43
51
 
44
- const isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
45
- const useIsomorphicLayoutEffect = isSSR ? React__namespace.useEffect : React__namespace.useLayoutEffect;
52
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React__namespace.useLayoutEffect : React__namespace.useEffect;
46
53
  function useMutableCallback(fn) {
47
54
  const ref = React__namespace.useRef(fn);
48
55
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
@@ -1176,10 +1183,10 @@ function createRenderer(_roots, _getEventPriority) {
1176
1183
  },
1177
1184
 
1178
1185
  createTextInstance: () => {
1179
- throw new Error('Text is not allowed in the R3F tree.');
1186
+ throw new Error('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
1180
1187
  },
1181
1188
  hideTextInstance: () => {
1182
- throw new Error('Text is not allowed in the R3F tree.');
1189
+ throw new Error('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
1183
1190
  },
1184
1191
  unhideTextInstance: () => {},
1185
1192
  // https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
@@ -37,12 +37,19 @@ var threeTypes = /*#__PURE__*/Object.freeze({
37
37
  __proto__: null
38
38
  });
39
39
 
40
- const isOrthographicCamera = def => def && def.isOrthographicCamera; // React currently throws a warning when using useLayoutEffect on the server.
41
- // To get around it, we can conditionally useEffect on the server (no-op) and
42
- // useLayoutEffect on the client.
40
+ var _window$document, _window$navigator;
41
+ const isOrthographicCamera = def => def && def.isOrthographicCamera;
42
+ /**
43
+ * An SSR-friendly useLayoutEffect.
44
+ *
45
+ * React currently throws a warning when using useLayoutEffect on the server.
46
+ * To get around it, we can conditionally useEffect on the server (no-op) and
47
+ * useLayoutEffect elsewhere.
48
+ *
49
+ * @see https://github.com/facebook/react/issues/14927
50
+ */
43
51
 
44
- const isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
45
- const useIsomorphicLayoutEffect = isSSR ? React__namespace.useEffect : React__namespace.useLayoutEffect;
52
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React__namespace.useLayoutEffect : React__namespace.useEffect;
46
53
  function useMutableCallback(fn) {
47
54
  const ref = React__namespace.useRef(fn);
48
55
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
@@ -1176,10 +1183,10 @@ function createRenderer(_roots, _getEventPriority) {
1176
1183
  },
1177
1184
 
1178
1185
  createTextInstance: () => {
1179
- throw new Error('Text is not allowed in the R3F tree.');
1186
+ throw new Error('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
1180
1187
  },
1181
1188
  hideTextInstance: () => {
1182
- throw new Error('Text is not allowed in the R3F tree.');
1189
+ throw new Error('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
1183
1190
  },
1184
1191
  unhideTextInstance: () => {},
1185
1192
  // https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-0499a96a.cjs.dev.js');
5
+ var index = require('./index-6716e497.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-ca47b633.cjs.prod.js');
5
+ var index = require('./index-8296e46a.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-6279214a.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-6279214a.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-2e68c2a1.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-2e68c2a1.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-0499a96a.cjs.dev.js');
5
+ var index = require('../../dist/index-6716e497.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-ca47b633.cjs.prod.js');
5
+ var index = require('../../dist/index-8296e46a.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-6279214a.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-6279214a.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-2e68c2a1.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-2e68c2a1.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.2.0",
3
+ "version": "8.2.1",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",