-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
React "Unknown props" warnings #64
Comments
It's a new feature in |
I could help. I just need to know how so that everything is done the same way. |
Okay - I'll do it in one of the packages. |
@radekmie this is the list of standard dom properties that are supported by react Do you think we can create a wrapper around this that shares a props object to two different objects, one with the allowed standard ones and other with the remaining, custom ones. this way, we can pass on the second one as props and use the first one where appropriate |
For reference, here's a proper const ALLOWED_STANDARD_HTML_PROPERTIES = [
"accept",
"acceptCharset",
"accessKey",
"action",
"allowFullScreen",
"allowTransparency",
"alt",
"async",
"autoComplete",
"autoPlay",
"capture",
"cellPadding",
"cellSpacing",
"charSet",
"challenge",
"checked",
"cite",
"classID",
"className",
"cols",
"colSpan",
"content",
"contentEditable",
"contextMenu",
"controls",
"coords",
"crossOrigin",
"data",
"dateTime",
"default",
"defer",
"dir",
"disabled",
"download",
"draggable",
"encType",
"form",
"formAction",
"formEncType",
"formMethod",
"formNoValidate",
"formTarget",
"frameBorder",
"headers",
"height",
"hidden",
"high",
"href",
"hrefLang",
"htmlFor",
"httpEquiv",
"icon",
"id",
"inputMode",
"integrity",
"is",
"keyParams",
"keyType",
"kind",
"label",
"lang",
"list",
"loop",
"low",
"manifest",
"marginHeight",
"marginWidth",
"max",
"maxLength",
"media",
"mediaGroup",
"method",
"min",
"minLength",
"multiple",
"muted",
"name",
"nonce",
"noValidate",
"open",
"optimum",
"pattern",
"placeholder",
"poster",
"preload",
"profile",
"radioGroup",
"readOnly",
"rel",
"required",
"reversed",
"role",
"rows",
"rowSpan",
"sandbox",
"scope",
"scoped",
"scrolling",
"seamless",
"selected",
"shape",
"size",
"sizes",
"span",
"spellCheck",
"src",
"srcDoc",
"srcLang",
"srcSet",
"start",
"step",
"style",
"summary",
"tabIndex",
"target",
"title",
"type",
"useMap",
"value",
"width",
"wmode",
"wrap",
"about",
"datatype",
"inlist",
"prefix",
"property",
"resource",
"typeof",
"vocab",
"autoCapitalize",
"autoCorrect",
"autoSave",
"color",
"itemProp",
"itemScope",
"itemType",
"itemID",
"itemRef",
"results",
"security",
"unselectable",
]; And we should also whitelist and send down all props that begin with |
Apart from the unknown props, there other other erros:
|
I think it's unnecessary @serkandurusoy - I've done it manually in |
I am right saying that it is not working because of those errors with react 15.0.2 ? I can't managed to have your simple example working... |
Okay, I think I've removed everything - comment here if you find something left. |
Seems like fixed, thanks! |
Missed one:
Happens only when you have a I guess that other custom SimpleSchema extensions would also be passed down. |
You also missed the
|
Well, those are from SimpleSchema, so I don't really know, what to do - it won't be a good idea to intercept every schema props from every field... I guess, that we have to go along with something like @serkandurusoy have suggested. I'll try to come up with something, but ideas are welcome (as always). |
Maybe SimpleSchema related props could be handled on a bridge-level, maybe only limited whitelisted props could be passed down to components? Other then that only solution I see is to filter out invalid values before passing them to elements. |
Simple schema options can be extended in which case whitelisting fields on for example, uniforms is a custom ss property! On Mon, Jul 11, 2016 at 7:50 PM, Maciek Stasiełuk notifications@github.com
|
I think that something like: export function filterDOMProps (props) {
// Either
props = {...props};
// or
props = Object.assign({}, props);
delete props.findError;
delete props.findField;
delete props.findType;
// ...
return props;
} in core package will be sufficient. What do you think? |
You will then need to maintain this and also anyone extending current components will also need to be aware of that. So instead, I think you should go the other way around. Filter out react's "known props" (the list I provided in an earlier comment) and do a |
I was thinking more about something like: export function filterDOMProps (props) {
const DOMProps = {};
for (let prop in props) {
if (
prop.startsWith('data-') ||
prop.startsWith('aria-') ||
ALLOWED_STANDARD_HTML_PROPERTIES.includes(prop)
) {
DOMProps[prop] = props[prop];
}
}
return DOMProps;
} Of course some testing and benchmarks would be nice to have. |
Yes, @MacRusher - that would be quite good, but some benchmarking is needed (that standard props array is big!). It's interesting, that React doesn't offer such function out of box. |
If we could write this in a way that browsers could be able to inline cache then this wouldn't be much of a problem, but I'm not sure at the moment if this is possible. |
Perhaps we could use a memoizing function to ease the re-evaluation? |
Memoization would help, if we will call it many times with same objects - we won't. |
it would at least help for apps that create the same components over and over again, would it not? And wow! So we go back to square one :) |
Closing time! I've added new |
And here is a little gem I've found during benchmarks.
Currently implemented is no. 3. Why Firefox is so slow? |
This seems to be the wrong way to go about this. My reasoning is like this:
To elaborate, even though a property of the standard definition, like I would expect, instead, for html attributes to be specified in the |
@BudgieInWA: sorry for the delay - I’m sure I’ve answered you but this comment seem to disappear. It makes more or less sense, depending on the schema and your background. If you come from Meteor Blaze autoform, then you integrate schema validation almost 1 to 1 with form attributes. Other thing is that it was somehow a design decision to make it as easy to start as possible and let users tweak it to their needs. Right now, you can change this behavior by explicitly setting some values to Remember, that it’s also possible to implement own schema bridge. You can easily fork default ones to work with your case and separate them. |
We had this problem when extending simpleschema. We solved it like this: const schmemaExtensions = ["interfieldvisibility"];
SimpleSchema.extendOptions(schmemaExtensions);
if (Meteor.isClient) {
schmemaExtensions.forEach((schmemaExtension) => {
filterDOMProps.register(schmemaExtension as any);
});
} |
@radekmie may make sense to add this to the documentation of simpleschema bridge? |
@michaellill-corefihub: Thanks for the suggestion! I believe we could just link to |
@radekmie Even better. Thank you! |
I'm not sure if this is intended or not but I get a bunch of "Unknown props" errors.
Per example:
The text was updated successfully, but these errors were encountered: