File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed 
docs/react-testing-library Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -226,23 +226,17 @@ Returns a `DocumentFragment` of your rendered component. This can be useful if
226226you need to avoid live bindings and see how your component reacts to events. 
227227
228228` ` ` jsx 
229+ import  React , { useState  } from  ' react' 
229230import  { render , fireEvent  } from  ' @testing-library/react' 
230231
231- class  TestComponent  extends  React .Component  {
232-  constructor () {
233-  super ()
234-  this .state  =  { count: 0  }
235-  }
236- 
237-  render() {
238-  const =  this .state 
232+ const  TestComponent  =  () =>  {
233+  const =  useState (0 )
239234
240-  return  (
241-  < button  onClick = {() => this.setState({ count : count  +  1  })}> 
242-  Click  to  increase :  {count}
243-  < / button > 
244-  )
245-  }
235+  return  (
236+  < button  onClick = {() => setCounter(count  = >  count  +  1 )}> 
237+  Click  to  increase :  {count}
238+  < / button > 
239+  )
246240}
247241
248242const  { getByText , asFragment  } =  render (<TestComponent  />)
                         You can’t perform that action at this time. 
           
                  
0 commit comments