Kaynağa Gözat

renderComment 暴露所有配置

narrowizard 6 yıl önce
ebeveyn
işleme
683ff01fa8
1 değiştirilmiş dosya ile 4 ekleme ve 12 silme
  1. 4
    12
      src/index.js

+ 4
- 12
src/index.js Dosyayı Görüntüle

@@ -5,7 +5,7 @@ import App, { Editor } from "./App";
5 5
 
6 6
 const Index = props => (
7 7
   <App showAlertComment showAlertReply showAlertFavor showError {...props}>
8
-    <Editor maxUpload={9} autoFocus />
8
+    <Editor maxUpload={9} autoFocus {...props.editorProps} />
9 9
   </App>
10 10
 );
11 11
 
@@ -26,26 +26,18 @@ function renderComment(config) {
26 26
   }
27 27
   if (!config.businessId) {
28 28
     // throw new Error("businessId is required");
29
+    config.businessId = "test";
29 30
     console.warn("没有传入 businessId 参数,默认使用: test");
30 31
   }
31 32
   if (!config.API) {
32 33
     // throw new Error("API is required");
34
+    config.API = "http://api.links123.net/comment/v1";
33 35
     console.warn(
34 36
       "没有传入 API 参数,默认使用: http://api.links123.net/comment/v1"
35 37
     );
36 38
   }
37
-  const {
38
-    id,
39
-    type = 1,
40
-    businessId = "test",
41
-    API = "http://api.links123.net/comment/v1",
42
-    userId
43
-  } = config;
44 39
 
45
-  ReactDOM.render(
46
-    <Index type={type} businessId={businessId} API={API} userId={userId} />,
47
-    document.getElementById(id)
48
-  );
40
+  ReactDOM.render(<Index {...config} />, document.getElementById(config.id));
49 41
   // registerServiceWorker();
50 42
 }
51 43