mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Start warning for JSX on plain functions
Let's also bump the version number for the log so that we can start filtering out the other logs.
This commit is contained in:
committed by
Paul O’Shannessy
parent
3c6c437d07
commit
bad1b7c41a
@@ -65,15 +65,16 @@ function warnForPlainFunctionType(type) {
|
||||
} catch (x) {
|
||||
// just incase this is a frozen object or some special object
|
||||
}
|
||||
monitorCodeUse('react_non_component_in_jsx', { name: type.name });
|
||||
monitorCodeUse(
|
||||
'react_non_component_in_jsx',
|
||||
{ version: 2, name: type.name }
|
||||
);
|
||||
}
|
||||
// TODO: This pattern is heavily used by ReactMenu and therefore we
|
||||
// cannot yet warn without spamming users too much.
|
||||
// warning(
|
||||
// false,
|
||||
// 'This JSX uses a plain function. Only React components are ' +
|
||||
// 'valid in React\'s JSX transform.'
|
||||
// );
|
||||
warning(
|
||||
false,
|
||||
'This JSX uses a plain function. Only React components are ' +
|
||||
'valid in React\'s JSX transform.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,11 +248,10 @@ describe('ReactDescriptor', function() {
|
||||
return 21 + x;
|
||||
});
|
||||
expect(factory(21)).toBe(42);
|
||||
// TODO: This warning is temporarily disabled
|
||||
expect(console.warn.argsForCall.length).toBe(0);
|
||||
// expect(console.warn.argsForCall[0][0]).toContain(
|
||||
// 'This JSX uses a plain function.'
|
||||
// );
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain(
|
||||
'This JSX uses a plain function.'
|
||||
);
|
||||
});
|
||||
|
||||
it('warns but allow a plain function to be immediately invoked', function() {
|
||||
@@ -261,11 +260,10 @@ describe('ReactDescriptor', function() {
|
||||
return 21 + x + y;
|
||||
}, 11, 10);
|
||||
expect(result).toBe(42);
|
||||
// TODO: This warning is temporarily disabled
|
||||
expect(console.warn.argsForCall.length).toBe(0);
|
||||
// expect(console.warn.argsForCall[0][0]).toContain(
|
||||
// 'This JSX uses a plain function.'
|
||||
// );
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain(
|
||||
'This JSX uses a plain function.'
|
||||
);
|
||||
});
|
||||
|
||||
it('warns but does not fail on undefined results', function() {
|
||||
@@ -273,11 +271,10 @@ describe('ReactDescriptor', function() {
|
||||
var fn = function () { };
|
||||
var result = React.createDescriptor(fn, 1, 2, null);
|
||||
expect(result).toBe(undefined);
|
||||
// TODO: This warning is temporarily disabled
|
||||
expect(console.warn.argsForCall.length).toBe(0);
|
||||
// expect(console.warn.argsForCall[0][0]).toContain(
|
||||
// 'This JSX uses a plain function.'
|
||||
// );
|
||||
expect(console.warn.argsForCall.length).toBe(1);
|
||||
expect(console.warn.argsForCall[0][0]).toContain(
|
||||
'This JSX uses a plain function.'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user