in React JS by
Q:

What is TestRenderer package in React?

1 Answer

0 votes
by

This package provides a renderer that can be used to render components to pure JavaScript objects, without depending on the DOM or a native mobile environment. This package makes it easy to grab a snapshot of the platform view hierarchy (similar to a DOM tree) rendered by a ReactDOM or React Native without using a browser or jsdom.

import TestRenderer from 'react-test-renderer'

const Link = ({page, children}) => <a href={page}>{children}</a>

const testRenderer = TestRenderer.create(
  <Link page={'https://www.facebook.com/'}>{'Facebook'}</Link>
)

console.log(testRenderer.toJSON())
// {
//   type: 'a',
//   props: { href: 'https://www.facebook.com/' },
//   children: [ 'Facebook' ]
// }
Click here to read more about React JS
Click here to read more about Insurance

Related questions

0 votes
asked Jan 30 in React JS by rajeshsharma
0 votes
asked May 20, 2020 in React JS by GeorgeBell
0 votes
asked Mar 3, 2020 in React JS by miceperry
0 votes
asked Jul 2, 2019 in React JS by Venkatshastri
0 votes
asked Jul 2, 2019 in React JS by Venkatshastri
...