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

@payloadcms/live-preview-react

Package Overview
Dependencies
Maintainers
4
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@payloadcms/live-preview-react - npm Package Compare versions

Comparing version 3.0.0-beta.16 to 3.0.0-beta.27

dist/RefreshRouteOnSave.d.ts

11

dist/index.d.ts

@@ -1,10 +0,3 @@

export declare const useLivePreview: <T extends unknown>(props: {
apiRoute?: string;
depth?: number;
initialData: T;
serverURL: string;
}) => {
data: T;
isLoading: boolean;
};
export { RefreshRouteOnSave } from './RefreshRouteOnSave.js';
export { useLivePreview } from './useLivePreview.js';
//# sourceMappingURL=index.d.ts.map

@@ -1,46 +0,4 @@

import { ready, subscribe, unsubscribe } from '@payloadcms/live-preview';
import { useCallback, useEffect, useRef, useState } from 'react';
// To prevent the flicker of missing data on initial load,
// you can pass in the initial page data from the server
// To prevent the flicker of stale data while the post message is being sent,
// you can conditionally render loading UI based on the `isLoading` state
export const useLivePreview = (props)=>{
const { apiRoute, depth, initialData, serverURL } = props;
const [data, setData] = useState(initialData);
const [isLoading, setIsLoading] = useState(true);
const hasSentReadyMessage = useRef(false);
const onChange = useCallback((mergedData)=>{
setData(mergedData);
setIsLoading(false);
}, []);
useEffect(()=>{
const subscription = subscribe({
apiRoute,
callback: onChange,
depth,
initialData,
serverURL
});
if (!hasSentReadyMessage.current) {
hasSentReadyMessage.current = true;
ready({
serverURL
});
}
return ()=>{
unsubscribe(subscription);
};
}, [
serverURL,
onChange,
depth,
initialData,
apiRoute
]);
return {
data,
isLoading
};
};
export { RefreshRouteOnSave } from './RefreshRouteOnSave.js';
export { useLivePreview } from './useLivePreview.js';
//# sourceMappingURL=index.js.map
{
"name": "@payloadcms/live-preview-react",
"version": "3.0.0-beta.16",
"version": "3.0.0-beta.27",
"description": "The official live preview React SDK for Payload",
"homepage": "https://payloadcms.com",
"repository": {

@@ -11,7 +12,16 @@ "type": "git",

"license": "MIT",
"homepage": "https://payloadcms.com",
"author": "Payload CMS, Inc.",
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"files": [
"dist"
],
"dependencies": {

@@ -22,4 +32,4 @@ "@payloadcms/live-preview": "^0.x"

"@types/react": "18.2.74",
"@payloadcms/eslint-config": "3.0.0-beta.16",
"payload": "3.0.0-beta.16"
"payload": "3.0.0-beta.27",
"@payloadcms/eslint-config": "1.1.1"
},

@@ -29,15 +39,5 @@ "peerDependencies": {

},
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"files": [
"dist"
],
"scripts": {

@@ -44,0 +44,0 @@ "build": "pnpm copyfiles && pnpm build:swc && pnpm build:types",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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