GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [React Native] Improve errors for invalid ViewConfig getter functions… · react/react@32e5c97

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-native-renderer/src
    • __mocks__/react-native/Libraries/ReactPrivate
      • ReactNativeViewConfigRegistry.js
    • __tests__
      • ReactNativeError-test.internal.js
  • scripts/rollup/shims/react-native
    • ReactNativeViewConfigRegistry.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/ReactNativeViewConfigRegistry.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/ReactNativeViewConfigRegistry.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ exports.register = function(name: string, callback: ViewConfigGetter): string {
7878
'Tried to register two views with the same name %s',
7979
name,
8080
);
81+
invariant(
82+
typeof callback === 'function',
83+
'View config getter callback for component `%s` must be a function (received `%s`)',
84+
name,
85+
callback === null ? 'null' : typeof callback,
86+
);
8187
viewConfigCallbacks.set(name, callback);
8288
return name;
8389
};
@@ -94,8 +100,9 @@ exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> {
94100
if (typeof callback !== 'function') {
95101
invariant(
96102
false,
97-
'View config not found for name %s.%s',
103+
'View config getter callback for component `%s` must be a function (received `%s`).%s',
98104
name,
105+
callback === null ? 'null' : typeof callback,
99106
typeof name[0] === 'string' && /[a-z]/.test(name[0])
100107
? ' Make sure to start component names with a capital letter.'
101108
: '',
Collapse file

‎packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js‎

Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ describe('ReactNativeError', () => {
3232
.computeComponentStackForErrorReporting;
3333
});
3434

35+
it('should throw error if null component registration getter is used', () => {
36+
expect(() => {
37+
try {
38+
createReactNativeComponentClass('View', null);
39+
} catch (e) {
40+
throw new Error(e.toString());
41+
}
42+
}).toThrow(
43+
'Invariant Violation: View config getter callback for component `View` must be a function (received `null`)',
44+
);
45+
});
46+
3547
it('should be able to extract a component stack from a native view', () => {
3648
const View = createReactNativeComponentClass('View', () => ({
3749
validAttributes: {foo: true},
Collapse file

‎scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js‎

Copy file name to clipboardExpand all lines: scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ exports.register = function(name: string, callback: ViewConfigGetter): string {
7575
'Tried to register two views with the same name %s',
7676
name,
7777
);
78+
invariant(
79+
typeof callback === 'function',
80+
'View config getter callback for component `%s` must be a function (received `%s`)',
81+
name,
82+
callback === null ? 'null' : typeof callback,
83+
);
7884
viewConfigCallbacks.set(name, callback);
7985
return name;
8086
};
@@ -91,8 +97,9 @@ exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> {
9197
if (typeof callback !== 'function') {
9298
invariant(
9399
false,
94-
'View config not found for name %s.%s',
100+
'View config getter callback for component `%s` must be a function (received `%s`).%s',
95101
name,
102+
callback === null ? 'null' : typeof callback,
96103
typeof name[0] === 'string' && /[a-z]/.test(name[0])
97104
? ' Make sure to start component names with a capital letter.'
98105
: '',

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.