Skip to content

Commit e65e598

Browse files
committed
refactor(deps): using local warning module instead of module from fbjs/lib and removing fbjs dep
1 parent eddd30e commit e65e598

File tree

5 files changed

+99
-4
lines changed

5 files changed

+99
-4
lines changed

package-lock.json

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-native-web/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"dependencies": {
2525
"@babel/runtime": "^7.18.6",
2626
"@react-native/normalize-colors": "^0.74.1",
27-
"fbjs": "^3.0.4",
2827
"inline-style-prefixer": "^6.0.1",
2928
"memoize-one": "^6.0.0",
3029
"nullthrows": "^1.1.1",

packages/react-native-web/src/exports/ScrollView/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import TextInputState from '../../modules/TextInputState';
2323
import UIManager from '../UIManager';
2424
import View from '../View';
2525
import React from 'react';
26-
import warning from 'fbjs/lib/warning';
26+
import warning from '../../modules/warning';
2727

2828
type ScrollViewProps = {
2929
...ViewProps,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-disable */
2+
'use strict';
3+
4+
function makeEmptyFunction(arg) {
5+
return function () {
6+
return arg;
7+
};
8+
}
9+
/**
10+
* This function accepts and discards inputs; it has no side effects. This is
11+
* primarily useful idiomatically for overridable function endpoints which
12+
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
13+
*/
14+
15+
var emptyFunction = function emptyFunction() {};
16+
17+
emptyFunction.thatReturns = makeEmptyFunction;
18+
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
19+
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
20+
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
21+
22+
emptyFunction.thatReturnsThis = function () {
23+
return this;
24+
};
25+
26+
emptyFunction.thatReturnsArgument = function (arg) {
27+
return arg;
28+
};
29+
30+
export default emptyFunction;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* eslint-disable */
2+
'use strict';
3+
4+
import emptyFunction from '../emptyFunction';
5+
/**
6+
* Similar to invariant but only logs a warning if the condition is not met.
7+
* This can be used to log issues in development environments in critical
8+
* paths. Removing the logging code for production environments will keep the
9+
* same logic and follow the same code paths.
10+
*/
11+
12+
function printWarning(format) {
13+
for (
14+
var _len = arguments.length,
15+
args = new Array(_len > 1 ? _len - 1 : 0),
16+
_key = 1;
17+
_key < _len;
18+
_key++
19+
) {
20+
args[_key - 1] = arguments[_key];
21+
}
22+
23+
var argIndex = 0;
24+
var message =
25+
'Warning: ' +
26+
format.replace(/%s/g, function () {
27+
return args[argIndex++];
28+
});
29+
30+
if (typeof console !== 'undefined') {
31+
console.error(message);
32+
}
33+
34+
try {
35+
// --- Welcome to debugging React ---
36+
// This error was thrown as a convenience so that you can use this stack
37+
// to find the callsite that caused this warning to fire.
38+
throw new Error(message);
39+
} catch (x) {}
40+
}
41+
42+
var warning =
43+
process.env.NODE_ENV !== 'production'
44+
? function (condition, format) {
45+
if (format === undefined) {
46+
throw new Error(
47+
'`warning(condition, format, ...args)` requires a warning ' +
48+
'message argument'
49+
);
50+
}
51+
52+
if (!condition) {
53+
for (
54+
var _len2 = arguments.length,
55+
args = new Array(_len2 > 2 ? _len2 - 2 : 0),
56+
_key2 = 2;
57+
_key2 < _len2;
58+
_key2++
59+
) {
60+
args[_key2 - 2] = arguments[_key2];
61+
}
62+
63+
printWarning.apply(void 0, [format].concat(args));
64+
}
65+
}
66+
: emptyFunction;
67+
68+
export default warning;

0 commit comments

Comments
 (0)