Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-cosmos-renderer

Package Overview
Dependencies
Maintainers
0
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cosmos-renderer - npm Package Compare versions

Comparing version 6.1.2-canary.5da46eb.0 to 6.1.2-canary.71267f3.0

21

dist/fixtureModule/createFixtureNode.js
import React from 'react';
import { isElement } from 'react-is';
export function createFixtureNode(fixture) {
// Warning: In a React Server Components setup this function is called on the
// server. When a fixture module uses the 'use client' directive, the fixture
// arg received here will be a function wrapper regardless of the fixture
// module contents. In this scenario, the fixture module will be automatically
// rendered on the client side, where React expects a component default export.
// export will be a Promise wrapper (imbued with magical properties methinks).
// This results in the following limitation: In a React Server Components
// setup, Client fixtures have to export a single function component. They
// can't be multi fixtures and they can't export React elements directly.
return isFunctionFixture(fixture) ? (React.createElement(FixtureElement, { Component: fixture })) : (fixture);
return isNodeFixture(fixture) ? (fixture) : (React.createElement(FixtureElement, { Component: fixture }));
}
function isFunctionFixture(fixture) {
return typeof fixture === 'function';
function isNodeFixture(fixture) {
// If you're curious what the exact type of ReactNode is:
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6fc4839a810335dee15374e6bc82dbbc2bbdff58/types/react/index.d.ts#L478-L489
return (fixture === undefined ||
fixture === null ||
typeof fixture === 'string' ||
typeof fixture === 'number' ||
typeof fixture === 'boolean' ||
Array.isArray(fixture) ||
// If you're curious what isElement checks:
// https://github.com/facebook/react/blob/1b0132c05acabae5aebd32c2cadddfb16bda70bc/packages/react-is/src/ReactIs.js#L108-L114
isElement(fixture));
}

@@ -16,0 +25,0 @@ function FixtureElement({ Component }) {

{
"name": "react-cosmos-renderer",
"version": "6.1.2-canary.5da46eb.0+5da46eb",
"version": "6.1.2-canary.71267f3.0+71267f3",
"description": "React Cosmos Renderer",

@@ -15,6 +15,6 @@ "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-renderer",

"lodash-es": "4.17.21",
"react-cosmos-core": "6.1.2-canary.5da46eb.0+5da46eb",
"react-cosmos-core": "6.1.2-canary.71267f3.0+71267f3",
"react-is": "18.2.0"
},
"gitHead": "5da46eb86dab5ebfb0d2b6a8273ca10a32deda2d"
"gitHead": "71267f34230c703f89e58b12a87a25572c9cd5d8"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc