( Component: any, baseProps: Object, )
| 2415 | } |
| 2416 | |
| 2417 | export function resolveClassComponentProps( |
| 2418 | Component: any, |
| 2419 | baseProps: Object, |
| 2420 | ): Object { |
| 2421 | let newProps = baseProps; |
| 2422 | |
| 2423 | // Remove ref from the props object, if it exists. |
| 2424 | if ('ref' in baseProps) { |
| 2425 | newProps = ({}: any); |
| 2426 | for (const propName in baseProps) { |
| 2427 | if (propName !== 'ref') { |
| 2428 | newProps[propName] = baseProps[propName]; |
| 2429 | } |
| 2430 | } |
| 2431 | } |
| 2432 | |
| 2433 | // Resolve default props. |
| 2434 | const defaultProps = Component.defaultProps; |
| 2435 | if (defaultProps) { |
| 2436 | // We may have already copied the props object above to remove ref. If so, |
| 2437 | // we can modify that. Otherwise, copy the props object with Object.assign. |
| 2438 | if (newProps === baseProps) { |
| 2439 | newProps = assign({}, newProps, baseProps); |
| 2440 | } |
| 2441 | // Taken from old JSX runtime, where this used to live. |
| 2442 | for (const propName in defaultProps) { |
| 2443 | if (newProps[propName] === undefined) { |
| 2444 | newProps[propName] = defaultProps[propName]; |
| 2445 | } |
| 2446 | } |
| 2447 | } |
| 2448 | |
| 2449 | return newProps; |
| 2450 | } |
| 2451 | |
| 2452 | function renderClassComponent( |
| 2453 | request: Request, |
no outgoing calls
no test coverage detected