ama icon indicating copy to clipboard operation
ama copied to clipboard

Testing hooks set with refs properties

Open benfluleck opened this issue 7 years ago • 1 comments

Thanks, for the good work and please keep it up. I am having a problem 😭 , Below, I have tried to show what my parent component looks like as a sandbox might take me a bit too long. I have also posted a snippet of what my InputTextfield component looks like and a pic for clarity. The issue i have is at the moment I am setting the paddingRight property of the textInput based on the width of the optional Element specified, this could be anything depending on what is passed in. I have used a combination of useState, useEffect and ref to get the width of the optional item. But I am not sure how I can test this behaviour with react-testing-library

https://codesandbox.io/s/zx0r4xxqol

<div>
  <TextInput
     id={inputextId}
     value={value}
     paddingRight={`${width}rem`}
   />
  <Label id={inputextId}>
     {label}
  </Label>
  <OptionalElement
     innerRef={optionalElementRef}
     optionalText={optionalText}
     showIcon={showIcon}
   />
 </div>

Screenshot 2019-03-12 at 11 18 02 AM

benfluleck avatar Mar 25 '19 19:03 benfluleck

@kentcdodds I have put it in a codesandbox. Thanks

benfluleck avatar Mar 25 '19 22:03 benfluleck