Skip to content

Commit d16f185

Browse files
authored
Fix CopyPromptButton crashing when rendered with no props (#513)
<CopyPromptButton /> with no attributes passes null props under the classic JSX transform, and destructuring defaults only apply to undefined, not null, so the homepage's default-prompt usage broke while the parameterized usage on the Foreman page kept working.
1 parent ec21b53 commit d16f185

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

snippets/copy-prompt-button.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const DEFAULT_PROMPT = `# Setup Kernel
2727
- Tell the user they can use the live view immediately.
2828
- If browser creation fails, stop and ask the user for help.`;
2929

30-
export const CopyPromptButton = ({ prompt = DEFAULT_PROMPT, label = 'copy prompt' } = {}) => {
30+
export const CopyPromptButton = (props) => {
31+
const { prompt = DEFAULT_PROMPT, label = 'copy prompt' } = props || {};
3132
const [copied, setCopied] = useState(false);
3233

3334
const handleCopy = useCallback(async () => {

0 commit comments

Comments
 (0)