Skip to content

Commit

Permalink
Merge pull request #392 from chintan9/fix/docs
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
chintan9 authored Oct 26, 2020
2 parents e1ab2ad + 662cd53 commit cd40f31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MyComponent extends Component {
render() {
return (
<>
<Plyr ref={(player) => (this.player = player)} />
<Plyr ref={(player) => (this.player.current = player)} />
</>
)
}
Expand Down
9 changes: 9 additions & 0 deletions test/Plyr.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ describe('<Plyr />', () => {
expect(ref.current.plyr).toBeDefined()
})

it('should render and have a plyr instance in ref.current when using a ref callback', () => {
const ref = createRef<any>() as any
const wrapper = mount(<Plyr ref={(player) => (ref.current = player)} />)

expect(wrapper).toBeDefined()
expect(ref.current).toBeDefined()
expect(ref.current.plyr).toBeDefined()
})

it('should render and keep a plyr instance after a rerender', () => {
const ref = createRef<any>()
const wrapper = mount(<Plyr ref={ref} />)
Expand Down

0 comments on commit cd40f31

Please sign in to comment.