customInput failed prop type with styled-component passed
See original GitHub issueHi, sorry but I got this error when I try to pass a styled-component
import styled from 'styled-components';
const StyledInput = styled((props) => (
<input {...props} />
))`
// my stylings...
`
to the customInput prop. The error that I got is the following
Failed prop type: Invalid prop
customInput
of typeobject
supplied toNumberFormat
, expectedfunction
.
However the app works just fine. What’s the cause of this if I may get a better understanding? Thank you in advance!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
React Number Format and Styled Components - props getting ...
Turned out React Number Format has a similar prop called customInput so the solution I found is doing it this way <NumberFormat customInput={ ......
Read more >Basics - styled-components
You can pass a function ("interpolations") to a styled component's ... Note how the inputColor prop is not passed to the DOM, but...
Read more >Complete Guide On How To Use Styled-components In React
You must pass in the className prop in the parent element of the component to be styled because with it styled component can...
Read more >[Solved]-Styled Component For Forms-Reactjs
Coding example for the question Styled Component For Forms-Reactjs. ... name="email" helperText={touched.email ? errors.email : ''} error={touched.email ...
Read more >Deciphering TypeScript's React errors | by Fiona Hopkins |
Getting a prop's type wrong, such as passing a string when it expects a number. If we write these bugs, TypeScript will show...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Had the same issue, but after changing the prop to a function wrapper seems to be workign as expecteed. The code that works:
Update: Seems that after applying this only the first key is registered, so still not working as expected
I have created a pull request which fixes this - the
function
prop-type is not quite correct and can now be replaced withPropTypes.elementType
. As a temporary workaround it’s possible to suppress the prop-type warning by wrapping your styled-component in a class component, e.g:This is not ideal but is another solution for those who stumble upon this.