Skip to content

Commit

Permalink
fix(docs): sandpack hook react addition validation fixed (nextui-org#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgarciadev authored Oct 5, 2023
1 parent 6555999 commit 8de357c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 2 additions & 3 deletions apps/docs/components/sandpack/use-sandpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export interface UseSandpackProps {
}

const importReact = 'import React from "react";';
const importAllReact = 'import * as React from "react";';

export const useSandpack = ({
files = {},
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions apps/docs/content/components/input/custom-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 8de357c

Please sign in to comment.