🎥 Make videos programmatically with React
docs: add cancelRender() guide
kaf-lamed-beyt98372324e1da
diff --git a/packages/docs/docs/cancel-render.md b/packages/docs/docs/cancel-render.mdnew file mode 100644index 0000000000..381e6487aa--- /dev/null+++ b/packages/docs/docs/cancel-render.md@@ -0,0 +1,58 @@+---+image: /generated/articles/docs-cancel-render.png+id: cancel-render+title: cancelRender()+sidebar_label: cancelRender()+crumb: "How to"+---++When you invoke the `cancelRender()` function, you're telling remotion to stop rendering all the frames.++`cancelRender()` throws a simple error — `"Rendering Cancelled"` — for now, and it prevents any video from being rendered.++## Example++The `cancelRender()` function can be triggered in any way. But in this example, a button element is used to call the API.++```tsx twoSlash {2, 30}+import React from "react";+import { AbsoluteFill, cancelRender, useCurrentFrame } from "remotion";++export const BaseRender: React.FC = () => {+ const frame = useCurrentFrame();++ return (+ <AbsoluteFill+ style={{+ fontFamily: "ubuntu",+ fontSize: "500",+ justifyContent: "center",+ alignItems: "center",+ backgroundColor: "#fff",+ }}+ >+ <h1>The current frame is {frame}</h1>+ <button+ type="button"+ style={{+ color: "#fff",+ height: "50px",+ width: "35%",+ fontSize: "22px",+ textAlign: "center",+ borderRadius: "4px",+ backgroundColor: "#0b84f3",+ border: "none",+ }}+ onClick={cancelRender}+ >+ Click me to cancel this render+ </button>+ </AbsoluteFill>+ );+};+```++When you click the button, you'd get an error similar to the one in the image below++diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 6d7e176bb7..a2c11d7d6b 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -83,6 +83,13 @@ export const articles = [compId: "articles-docs-bundler",crumb: null,},+ {+ id: "cancel-render",+ title: "cancelRender()",+ relativePath: "docs/cancel-render.md",+ compId: "articles-docs-cancel-render",+ crumb: "How to",+ },{id: "chromium-flags",title: "Chromium flags",diff --git a/packages/docs/static/img/cancel-render/error.png b/packages/docs/static/img/cancel-render/error.pngnew file mode 100644index 0000000000..63ec83690aBinary files /dev/null and b/packages/docs/static/img/cancel-render/error.png differ