File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
website/src/pages/example Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ export function babelTransform(input: string, filename: string) {
88}
99
1010export const getTransformValue = ( str : string , filename : string , funName : string ) => {
11- const isReact = / i m p o r t R e a c t . + f r o m ( " | ' ) r e a c t ( " | ' ) / . test ( str ) ;
11+ const isReact = / i m p o r t \x20 + R e a c t ( \x20 + | [ \x20 + , ] + ( { [ a - z A - Z 0 - 9 , \s ] + } | { } ) \x20 + ) f r o m \x20 + ( ' | " ) r e a c t ( ' | " ) / . test ( str ) ;
1212 // 先判断 是否引入 react
1313 const tran = isReact ? str : `import React from "react"\n ${ str } ` ;
1414 /** 先把默认导出 export default 进行替换 **/
15- const newCode = `${ tran . replace ( ' export default' , 'const _default = ' ) } \n` ;
15+ const newCode = `${ tran . replace ( / e x p o r t \x20 + d e f a u l t / , 'const _default = ' ) } \n` ;
1616 const code = `${ babelTransform ( newCode , `${ filename } ` ) . code } \n return _react["default"].createElement(_default)` ;
1717
1818 return `function ${ funName } (){
Original file line number Diff line number Diff line change @@ -11,11 +11,14 @@ import { Alert } from "uiw";
1111// or
1212import Alert from " @uiw/react-alert" ;
1313```
14-
14+ ` import React from 'react' `
1515## Basic Usage
1616
1717``` jsx mdx:preview
18- import React from " react" ;
18+ import React,{
19+ useState ,
20+ useEffect ,
21+ } from " react" ;
1922import ReactDOM from " react-dom" ;
2023import { Alert , ButtonGroup , Button } from " uiw" ;
2124
You can’t perform that action at this time.
0 commit comments