Skip to content

Commit 7de8383

Browse files
acdliteAndyPengc12
authored andcommitted
Delete duplicate jsx() implementation (facebook#28258)
Not sure how this happened but there are two identical implementations of the jsx and jsxDEV functions. One of them was unreachable. I deleted that one.
1 parent 7301686 commit 7de8383

File tree

2 files changed

+2
-160
lines changed

2 files changed

+2
-160
lines changed

packages/react/src/ReactElementProd.js

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -201,160 +201,6 @@ function ReactElement(type, key, ref, self, source, owner, props) {
201201
return element;
202202
}
203203

204-
/**
205-
* https://github.com/reactjs/rfcs/pull/107
206-
* @param {*} type
207-
* @param {object} props
208-
* @param {string} key
209-
*/
210-
export function jsx(type, config, maybeKey) {
211-
let propName;
212-
213-
// Reserved names are extracted
214-
const props = {};
215-
216-
let key = null;
217-
let ref = null;
218-
219-
// Currently, key can be spread in as a prop. This causes a potential
220-
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
221-
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
222-
// but as an intermediary step, we will use jsxDEV for everything except
223-
// <div {...props} key="Hi" />, because we aren't currently able to tell if
224-
// key is explicitly declared to be undefined or not.
225-
if (maybeKey !== undefined) {
226-
if (__DEV__) {
227-
checkKeyStringCoercion(maybeKey);
228-
}
229-
key = '' + maybeKey;
230-
}
231-
232-
if (hasValidKey(config)) {
233-
if (__DEV__) {
234-
checkKeyStringCoercion(config.key);
235-
}
236-
key = '' + config.key;
237-
}
238-
239-
if (hasValidRef(config)) {
240-
ref = config.ref;
241-
}
242-
243-
// Remaining properties are added to a new props object
244-
for (propName in config) {
245-
if (
246-
hasOwnProperty.call(config, propName) &&
247-
!RESERVED_PROPS.hasOwnProperty(propName)
248-
) {
249-
props[propName] = config[propName];
250-
}
251-
}
252-
253-
// Resolve default props
254-
if (type && type.defaultProps) {
255-
const defaultProps = type.defaultProps;
256-
for (propName in defaultProps) {
257-
if (props[propName] === undefined) {
258-
props[propName] = defaultProps[propName];
259-
}
260-
}
261-
}
262-
263-
return ReactElement(
264-
type,
265-
key,
266-
ref,
267-
undefined,
268-
undefined,
269-
ReactCurrentOwner.current,
270-
props,
271-
);
272-
}
273-
274-
/**
275-
* https://github.com/reactjs/rfcs/pull/107
276-
* @param {*} type
277-
* @param {object} props
278-
* @param {string} key
279-
*/
280-
export function jsxDEV(type, config, maybeKey, source, self) {
281-
let propName;
282-
283-
// Reserved names are extracted
284-
const props = {};
285-
286-
let key = null;
287-
let ref = null;
288-
289-
// Currently, key can be spread in as a prop. This causes a potential
290-
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
291-
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
292-
// but as an intermediary step, we will use jsxDEV for everything except
293-
// <div {...props} key="Hi" />, because we aren't currently able to tell if
294-
// key is explicitly declared to be undefined or not.
295-
if (maybeKey !== undefined) {
296-
if (__DEV__) {
297-
checkKeyStringCoercion(maybeKey);
298-
}
299-
key = '' + maybeKey;
300-
}
301-
302-
if (hasValidKey(config)) {
303-
if (__DEV__) {
304-
checkKeyStringCoercion(config.key);
305-
}
306-
key = '' + config.key;
307-
}
308-
309-
if (hasValidRef(config)) {
310-
ref = config.ref;
311-
warnIfStringRefCannotBeAutoConverted(config);
312-
}
313-
314-
// Remaining properties are added to a new props object
315-
for (propName in config) {
316-
if (
317-
hasOwnProperty.call(config, propName) &&
318-
!RESERVED_PROPS.hasOwnProperty(propName)
319-
) {
320-
props[propName] = config[propName];
321-
}
322-
}
323-
324-
// Resolve default props
325-
if (type && type.defaultProps) {
326-
const defaultProps = type.defaultProps;
327-
for (propName in defaultProps) {
328-
if (props[propName] === undefined) {
329-
props[propName] = defaultProps[propName];
330-
}
331-
}
332-
}
333-
334-
if (key || ref) {
335-
const displayName =
336-
typeof type === 'function'
337-
? type.displayName || type.name || 'Unknown'
338-
: type;
339-
if (key) {
340-
defineKeyPropWarningGetter(props, displayName);
341-
}
342-
if (ref) {
343-
defineRefPropWarningGetter(props, displayName);
344-
}
345-
}
346-
347-
return ReactElement(
348-
type,
349-
key,
350-
ref,
351-
self,
352-
source,
353-
ReactCurrentOwner.current,
354-
props,
355-
);
356-
}
357-
358204
/**
359205
* Create and return a new ReactElement of the given type.
360206
* See https://reactjs.org/docs/react-api.html#createelement

packages/react/src/ReactElementValidator.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ import checkPropTypes from 'shared/checkPropTypes';
2525
import isArray from 'shared/isArray';
2626

2727
import ReactCurrentOwner from './ReactCurrentOwner';
28-
import {
29-
isValidElement,
30-
createElement,
31-
cloneElement,
32-
jsxDEV,
33-
} from './ReactElementProd';
28+
import {isValidElement, createElement, cloneElement} from './ReactElementProd';
29+
import {jsxDEV} from './jsx/ReactJSXElement';
3430
import {setExtraStackFrame} from './ReactDebugCurrentFrame';
3531
import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame';
3632
import hasOwnProperty from 'shared/hasOwnProperty';

0 commit comments

Comments
 (0)