Shallow renders though portal child#1761
Conversation
| if (el.$$typeof === Portal) { | ||
| return { | ||
| nodeType: nodeTypeFromType(Portal), | ||
| type: Portal, |
There was a problem hiding this comment.
4854d43 to
9cf359f
Compare
| if (!type) return null; | ||
|
|
||
| if (type === Portal) { | ||
| return 'Portal'; |
There was a problem hiding this comment.
Same question as on the other PR; should we add this here, or only on the adapters?
|
|
||
| export function elementToTree(el) { | ||
| if (el === null || typeof el !== 'object' || !('type' in el)) { | ||
| if (el === null || typeof el !== 'object' || !('type' in el || el.$$typeof === Portal)) { |
There was a problem hiding this comment.
the $$typeof part should definitely not be here; that should be adapter-specific.
6ef7f24 to
5d24796
Compare
|
| } | ||
|
|
||
| export function elementToTree(el) { | ||
| export function elementToTree(el, wrapperElementToTree = null) { |
There was a problem hiding this comment.
@ljharb is there a nicer way to do this? One option would be to replace elementToTree entirely in the 16+ adapters, but we can't just replace the top level calls and fall through like displayNameOfNode and nodeTypeFromType since this is recursive
There was a problem hiding this comment.
good point. i guess this could be like recurse = elementToTree, and then use recurse below?
There was a problem hiding this comment.
The default second argument would break .map(elementToTree) since that provides a second index arg. Im not sure if its nicer to switch the .maps or leave this as typeof recurse === 'function'
| } | ||
|
|
||
| function elementToTree(el) { | ||
| if (!(el && el.$$typeof === Portal)) { |
There was a problem hiding this comment.
i think this line can be if (!isPortal(el)) {?
| } | ||
|
|
||
| function elementToTree(el) { | ||
| if (!(el && el.$$typeof === Portal)) { |
| } | ||
|
|
||
| function elementToTree(el) { | ||
| if (!(el && el.$$typeof === Portal)) { |
| } | ||
|
|
||
| function nodeTypeFromType(type) { | ||
| if (type && type === Portal) { |
There was a problem hiding this comment.
if type is falsy, it won't === Portal, so i think this can be type === Portal ? 'portal' : utilNodeTypeFromType(type)
| } | ||
|
|
||
| export function elementToTree(el) { | ||
| export function elementToTree(el, wrapperElementToTree = null) { |
There was a problem hiding this comment.
good point. i guess this could be like recurse = elementToTree, and then use recurse below?
73a2aa0 to
61ef730
Compare
0982fbc to
892d368
Compare
- [New] Add Portal support (#1760, #1761, #1772, #1774, @jgzuke) - [New] Add pointer events support (#1753, @ljharb) - [New] Add `displayNameOfNode`, `isValidElementType` (#1701, @jquense) - [New] pass the adapter into `createMountWrapper` (#1592, @jquense) - [Fix] `shallow`: skip updates when nextState is `null` or `undefined` (#1785, @koba04) - update deps - [meta] ensure a license and readme is present in all packages when published
- [New] Add forwardRef support (#1592, @jquense) - [New] Add Portal support (#1760, #1761, #1772, #1774, @jgzuke) - [New] Add pointer events support (#1753, @ljharb) - [New] Add `displayNameOfNode`, `isValidElementType` (#1701, @jquense) - [New] pass the adapter into `createMountWrapper` (#1592, @jquense) - [Fix] preemptively fix compat with React v16.4.3 (#1790, #1778, @gaearon, @aweary) - [Fix] `shallow`: skip updates when nextState is `null` or `undefined` (#1785, @koba04) - update deps - [meta] ensure a license and readme is present in all packages when published
- [New] Add forwardRef support (#1592, @jquense) - [New] Add Portal support (#1760, #1761, #1772, #1774, @jgzuke) - [New] Add pointer events support (#1753, @ljharb) - [Fix] preemptively fix compat with React v16.4.3 (#1790, #1778, @gaearon, @aweary) - [Fix] `shallow`: prevent rerenders with PureComponents (#1786, @koba04) - [Fix] `shallow`: skip updates when nextState is `null` or `undefined` (#1785, @koba04) - [Fix] `shallow`: `setState` after `setProps` calls `componentWillReceiveProps` (#1779, @peanutenthusiast) - [Fix] `mount`/`shallow`: be stricter on the wrapper’s setState/setProps callback - [Fix] `shallow`/`mount`: improve error message when wrapping invalid elements (#1759, @jgzuke) - update deps - [Refactor] remove most uses of lodash - [meta] ensure a license and readme is present in all packages when published
elementToTreewhen given aPortalelement returns a wrapper node and renders through children. Previously this would just return the element itself which would show in debug as<Portal />but not render through any children.