-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Search Component: Unknown props error #1141
Comments
The extra props passed to each |
To be clear, a The |
I have to ask this again... |
This may be the best practice, but annoying in this instance as I assumed defining a custom renderer would allow I'd also like to say that I agree with @koernchen02 and either would like to be able to define custom fields like he talks about or have the control over which props get used in the custom renderer. |
Whoa, looks like I misunderstood this one completely guys. Appreciate the extra effort to reach me. The user should definitely have full control over every prop used in all our components. @jcarbo your eyes appreciated on this: Looking at the code again, it looks like there is no way for the user to control the props of the My thinking is that the Thoughts? |
Returning a |
(comment updated) Hi
|
Heads up, these are two separate issues. The issue here is in the logic of the result renderer itself. The issue fixed by #1599 deals strictly with the Modal component. |
Any news on this issue? |
Doesn't appear so. Just waiting for a PR. |
@levithomason Thanks for your response but do you know if there is someone working on that? |
I don't see a pull request that address this. I have a question though: Isn't it neater to have SearchResult as a Higher Order Component and pass along all props to a the custom/default resultRenderer? |
Search component in the current state is too opinionated. Additionally: /** A unique identifier. */
id: PropTypes.number, Em, why number? This should allow for string input to. For results from MongoDB where ID is a string. |
In my case I'm happy enough with the default renderer, but I'm having a related issue where I want to conditionally process the result in
If you include extra properties on result objects there isn't even a warning as of React 16 - they simply get added as attributes to the My workaround at the moment is to repurpose the Additionally, for a category search you should be able to retrieve the category name and/or key for the result in |
Is this a duplicate of: #1681 ? |
@imns how did you eventually get around this? |
@josh91hickman I think I just ended up using something else. This was a year ago so I don't 100% remember to be honest. |
This issue is quite annoying for me as I've error on the console that sometimes break the UI flow like clicking on a button twice. A workaround is to use |
Any solutions for this? |
Not yet. However, from my slowly growing understanding of React, I think this evolution here mayy solve this particular issue: https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html Thoughts, @levithomason ? |
I don't use the search component. Someone from the community will need to step up for this one. |
Any luck with Pull Requests getting tested/merged? 😋 |
Any updates? |
This seems like you have to jump through non-intuitive hoops to get something simple to work. |
@imns in your original example, where is |
@martindale in this example it was from FeathersJS, but it could be any HTTP client though. |
I ended up creating my own search bar with an |
I was able to resolve the issue by deleting the offending prop (userID, in my case) from the object in the results array. I wasn't using it in the click handler anyhow. |
Why consumer of this component being force to use object schema predefined by author/contributor of this component, which is like |
I agree with everyone in this thread -- determining what props are allowable, such as arbitrary values like However, it doesn't appear this is going to be fixed anytime soon. As such I moved forward with iamdanthedev's solution from above, with one small change. In the item I was rendering I included the property Hope this helps and I hope this gets fixed!! |
Based on tom-wagner comment and iamdanthedev's suggest work around I am closing this. |
Unknown props like other meta data of my search show on html as attribute and it is because of unhandled props, so what if you handle the props like create prop of "metadata" or "data" where we pass other property to that prop so it will not show in the DOM and pass that prop when selecting result. Example of passing other props (although, no errors being shown, it is kinda awkward to see these attributes on the DOM): |
My solution for this is to add the object as the description as a JSON string. e.g. and in my results renderer I convert it back to an object.
|
|
You need to parse it in your results renderer before it's displayed |
No real fix for this at the moment (Sep 2019). Does anyone have thoughts about how should a PR looks like? Any guidelines? I could give it a try :) |
@iamdanthedev's code did not fix my error. still get 'Invalid prop Also, should I be worried about this issue breaking my app? Since everything is rendering just fine, am i missing something here? |
So there is no fix for this still?
|
I just deleted a rant. I appreciate all you do, but this Search component is WAY too opinionated. It should just allow simple custom rendering of arbitrary user data. I'm just going to write my own that doesn't include random key assignment and required titles and stuff like that. That seems to be what most people end up doing. |
@iamdanthedev where does the mapToSearchResult function go/ where does it get called? |
I have a search component with a custom renderer and I keep getting the error
Warning: Unknown props
_id,
url, ... on <div> tag. Remove these props from the element.
.The array I pass to results has these extra props, mentioned in the error, but I am using a custom renderer, so it seems to me they should be ignored.
Here is my custom renderer
My component is really simple
The above code is what's causing the warning.
The text was updated successfully, but these errors were encountered: