How to have data attribute on Custom component?

I want to do something like <Foo data-something = { 'hello' } /> How to provide data props ?
7 Replies
lxsmnsyc
lxsmnsyc2y ago
const Foo = (props) => <div data-value={props['data-value']} />?
musiclover
musiclover2y ago
But I don't know it will be 'data-value', it can be data-anything like we do in plain <div>
lxsmnsyc
lxsmnsyc2y ago
How can't you know something that's going to be passed to Foo? unless you're spreading in which case you spread it to the div too
musiclover
musiclover2y ago
I'm making generic component which can get any data attribute. Isn't it possible?
lxsmnsyc
lxsmnsyc2y ago
It's possible, but if you don't know the props its going to receive then you just spread it const Foo = (props) => <div {...props} />
musiclover
musiclover2y ago
But using {...props} will add all other props doesn't need to be custom attribute in div.
lxsmnsyc
lxsmnsyc2y ago
then just select which one to not spread using splitProps or probably omitProps from solid-primitives or solid-use