From 8de357cfacd03ef406047b8d475d342adfa75a5e Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Thu, 5 Oct 2023 12:17:27 -0300 Subject: [PATCH] fix(docs): sandpack hook react addition validation fixed (#1740) --- apps/docs/components/sandpack/use-sandpack.ts | 5 ++--- apps/docs/content/components/input/custom-impl.ts | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/docs/components/sandpack/use-sandpack.ts b/apps/docs/components/sandpack/use-sandpack.ts index 81fde7a91e..b75820aa4e 100644 --- a/apps/docs/components/sandpack/use-sandpack.ts +++ b/apps/docs/components/sandpack/use-sandpack.ts @@ -16,7 +16,6 @@ export interface UseSandpackProps { } const importReact = 'import React from "react";'; -const importAllReact = 'import * as React from "react";'; export const useSandpack = ({ files = {}, @@ -102,8 +101,8 @@ export const useSandpack = ({ let fileContent = files[key] as string; // Check if the file content includes 'React' import statements, if not, add it - if (!fileContent.includes(importReact) && !fileContent.includes(importAllReact)) { - fileContent = `${importReact}\n\n${fileContent}\n`; + if (!fileContent.includes("from 'react'") && !fileContent.includes('from "react"')) { + fileContent = `${importReact}\n${fileContent}\n`; } // Check if file content includes any other dependencies, if yes, add it to dependencies diff --git a/apps/docs/content/components/input/custom-impl.ts b/apps/docs/content/components/input/custom-impl.ts index e73cc23204..55533e508b 100644 --- a/apps/docs/content/components/input/custom-impl.ts +++ b/apps/docs/content/components/input/custom-impl.ts @@ -45,8 +45,6 @@ const CloseFilledIcon = `export const CloseFilledIcon = (props) => ( const App = `import React, {forwardRef} from "react"; import {useInput} from "@nextui-org/react"; - - import {SearchIcon} from "./SearchIcon"; import {CloseFilledIcon} from "./CloseFilledIcon";