M
M
midia212021-04-21 11:55:56
React
midia21, 2021-04-21 11:55:56

How to inherit base props from react elements in react components?

I noticed that in some libraries, for example
react-swiper, all the basic props of react elements are available for components.
For example, if you look at the intellisense for the component, you can see all
the properties available to regular tags (button, a, div):
from className to accessibility properties. + all event handlers are specified (onClick, onMouseOver, onMouseDown). Actually the question is: did they manually register all these props or is there some way to automatically inherit them?
I just thought it would be cool if the components in my application had all the basic properties immediately available. And now you have to run, for example, to the button component and add onDoubleClick, onFocus, className, etc. as necessary. Often these properties are simply redirected to the top element of the component...

Probably, something similar can be done in this way: but in this case, intellisense does not work, and therefore it seems to me that there is another, more flexible solution.
<div className='component-wrapper' {...props}>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question