-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
✨ Proof of concept React BaseElement #24153
Conversation
* @return {*} | ||
*/ | ||
render() { | ||
const props = pick(this.props, ATTRIBUTES_TO_PROPAGATE); |
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.
Are these not camel-cased?
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.
It's a local binding at the top of the array.
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.
I meant: are the attributes->props camel-cased? I.e. should it be "aria-label" or "ariaLabel"?
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.
Playing around, it appears to work either way... I'm not sure. aria-label
should definitely be lowercase, though: https://reactjs.org/docs/dom-elements.html.
constructor(props) { | ||
super(props); | ||
|
||
this.state = {prerender: true}; |
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.
Definitely subject to bikeshedding, but imho, this should be something like "loading=auto|manual", since there might be other reasons to block rendering, besides prerendering.
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.
Yup, I'm not tied to prerender
at all, it just the first name I thought of.
- noprerender - auto-sizes - auto generate src when srcset isn't supported
props['decoding'] = 'async'; | ||
|
||
const {prerender} = this.state; | ||
if (prerender && !this.prerenderAllowed_) { |
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.
I'm curious, why is this.state. prerender
and this.prerenderAllowed_
needed? Why not directly check the prop value for noprerender
to determine if src
and srcset
should be deleted?
if (!this.props.noprerender) {
delete props['src'];
delete props['srcset'];
}
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.
Hi!
I think we actually meant to do !prerender || !this.prerenderAllowed
. Note that we have to different sources here, one from this.state.prerender
(which is outside-of-React props being passed to React) and props.noprerender
(which is both the DOM-React and React-React possible values). We use the state
to control from the AMP framework, and props to allow the publisher to control behavior.
Also, this PR is stagnant. We started a new attempt at #25969. Feel free to follow along!
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.
Thanks for the info!
This is a proof of concept to support
React
/Preact
Components in AMP pages. Once we flesh this out, we can provide a generic class factory to createAMP.BaseElement
classes for each wrapped Component, which can then be registered and used like regular AMP components.A lot of the hard work was already done in
<amp-date-picker>
.