-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support react 16 (quick way) #11
Conversation
@ngryman Can you describe why the breaking change occurs? |
It seems like this just keeps using the unstable API and so avoids the breaking change? |
@jdeal Fixed the CI to highlight the issue: https://travis-ci.org/zapier/react-element-portal/builds/290528365#L1499 |
I see now @ngryman. That's definitely a breaking change. I think we'll want to allow passing in a callback instead. So something like:
That way we can call the callback before we render, similar to how we grab props from |
@jdeal Yeah I've thought about that and it's the better compromise I think. If we're doing so, why not having only this callback and deprecate the |
@ngryman I'm okay with that, but I do feel like the |
With the introduction of import dataAttributes from 'data-attributes'
const mapDomNodeToProps = (node) => ({
data: dataAttributes(node)
})
<ElementPortal selector=".target" view={Component} mapDomNodeToProps={mapDomNodeToProps} /> |
Breaking change: The new way of passing data from the target node to the transported component is implemented via the mapDomNodeToProps function that takes the target node as input and binds the output object to the transported component.
@ngryman I'm cool with that change, but can you replace the current |
Let bundlers use the source instead of the pre-bundled version. Also very helpful for ad-hoc testing.
I've updated the docs, please correct/enhance my English :) While patching Meanwhile, if you think everything is ok for the React 16 migration, please tell me so I can reference it in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ngryman A couple small wording tweaks, but otherwise we're good!
README.md
Outdated
`ElementPortal` also accepts an optional `view` prop that takes a component, to be rendered inside the portal: | ||
|
||
```js | ||
<ElementPortal id="header" view={CoolHeaderComponent} /> | ||
``` | ||
|
||
One advantage of using the `view` prop to specify a component is that any `data-` attributes from the DOM node the portal is rendering to will be passed along to our component as a `data` prop. | ||
For example, if the DOM node we are rendering to looks like this: | ||
One advantage of using the `view` prop to the ability to derive properties from the original DOM node to the the component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want something like:
One advantage of using the
view
prop is the ability to derive properties from the original DOM node and pass them to the the component.
README.md
Outdated
) | ||
``` | ||
|
||
By using the `mapDomNodeToProps` you can easily pass this data like so: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small tweak here:
By using the
mapDomNodeToProps
prop, you can easily pass this data like so:
This PR takes the fastest path to support React 16 with one breaking change: the
domNode
passed to the component is already mutated so referring to itstextContent
will not work anymore.I've skipped the associated test for now and wait for opinions on how to handle this.
cc @jdeal @vitorbal
ref #10