{"library":"react-shallow-renderer","title":"React Shallow Renderer","description":"React Shallow Renderer provides a utility for unit testing React components by rendering them \"one level deep.\" This means it asserts facts about a component's `render` method output without instantiating or rendering child components, and crucially, without requiring a DOM environment. The current stable version is 16.15.0, with the last significant update in October 2020. While historically useful for isolating component logic, React's official documentation for React 19 explicitly recommends against shallow rendering, urging developers to migrate to `@testing-library/react` or `@testing-library/react-native` for more robust and maintainable tests that focus on user behavior rather than implementation details. The package has not seen active development recently, making it a lower-level alternative compared to libraries like Enzyme, which offers a more feature-rich API over similar shallow rendering functionality.","language":"javascript","status":"deprecated","last_verified":"Sun Apr 19","install":{"commands":["npm install react-shallow-renderer"],"cli":null},"imports":["import ShallowRenderer from 'react-shallow-renderer';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import ShallowRenderer from 'react-shallow-renderer';\nimport React from 'react';\n\nfunction Subcomponent(props) {\n  return <span>Sub: {props.foo}</span>;\n}\n\nfunction MyComponent() {\n  return (\n    <div>\n      <span className=\"heading\">Title</span>\n      <Subcomponent foo=\"bar\" />\n    </div>\n  );\n}\n\n// In your test file:\nconst renderer = new ShallowRenderer();\nrenderer.render(<MyComponent />);\nconst result = renderer.getRenderOutput();\n\nconsole.log('Rendered output type:', result.type);\nconsole.log('Rendered output props:', result.props);\n\n// Example assertions (requires a testing framework like Jest)\n// expect(result.type).toBe('div');\n// expect(result.props.children).toEqual([\n//   <span className=\"heading\">Title</span>,\n//   <Subcomponent foo=\"bar\" />,\n// ]);","lang":"javascript","description":"Demonstrates basic shallow rendering of a component and accessing its top-level output and props for testing.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}