Skip to content

Custom data attributes and other Custom Component Things #4530

Answered by ebonow
Cuttsy27 asked this question in Q&A
Discussion options

You must be logged in to vote

Greetings @Cuttsy27 ,

Custom components accept a prop called innerProps which are passed to the component's root element.

const SelectContainer = props => {
  <components.SelectContainer 
    {...props} 
    innerProps={{...props.innerProps, 'data-test-id': 'some-id' }}
  />
)

codesandbox demo

Please note that there are a few exceptions currently (Input, GroupHeading) that instead pass extra prop attributes directly to the component (this will be patched in v5).

ie:

const Input = <components.Input {...props} autocomplete="chrome-off" />

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Cuttsy27
Comment options

Answer selected by Cuttsy27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants