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:
Sebastian Markbage
2014-08-29 14:35:07 -07:00
committed by Paul O’Shannessy
parent 3c6c437d07
commit bad1b7c41a
2 changed files with 21 additions and 23 deletions
+9 -8
View File
@@ -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.'
);
}
}
+12 -15
View File
@@ -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.'
);
});