{errors&&Error: Please add your name});};rest">
I have the following component in my React JS application:
const Input = ({name, ..rest}) => { return ({errors && Errors: Please add your name}); };
rest
The parameters include allReact.InputHTMLAttributes
, such as required, className, id, etc.
I'm having trouble trying to add the style
attribute to an Input component. If I add something like this:
margin-bottom: 45px
Then there will be a blank space between the input box and span, but this blank should be the spacing of the entire component, so the spacing should be applied below the component rather than between the elements of the component.
How can I avoid this problem and preserve the ...rest
attribute on the input tag?
Note: In addition to style
, you can also use className
, id
, in the same context ;required
etc.
You can extract the
style
attribute fromrest
, then delete itsmargin
attribute (set previously) and use your custommarginBottom: 45
override it.