Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to get the elements after rerender #1290

Unanswered
19Qingfeng asked this question in Q&A
Discussion options

I have reviewed the documentation, but still haven't found how to obtain the re rendered elements, eg:

 const ref = createRef<TabInstance>();
 const { rerender,getByRole } = render(<TabComponent headerRef={ref} />);
 const input = getByRole('textbox')
 expect(ref.current).toBeDefined();
 rerender(<TabComponent headerRef={ref} value="3" />)
 
 // May I ask how to obtain the rendered `const input = getByRole('textbox')` element

I'm not sure how I should obtain it, I haven't found any valid information on the document

You must be logged in to vote

Replies: 1 comment

Comment options

Hi @19Qingfeng.
I'm not sure I'm following the purpose of this test.
Using ref inside a test isn't a best practice since when we're testing we should act as if we're the user using our app.
If you want to test this component, I'd assert on what the user is actually seeing, if the value 3 is presented, I'd assert that.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /