Bläddra i källkod

update hooks using for demo

iou90kant 4 år sedan
förälder
incheckning
87a755419d
1 ändrade filer med 11 tillägg och 11 borttagningar
  1. 11
    11
      demo/App.js

+ 11
- 11
demo/App.js Visa fil

54
 const onWidthLoadEnd = () => console.log('width on load end');
54
 const onWidthLoadEnd = () => console.log('width on load end');
55
 
55
 
56
 const Explorer = () => {
56
 const Explorer = () => {
57
-  const [{ widthHtml, heightHtml }, setHtml] = useState(() => ({
57
+  const [{ widthHtml, heightHtml }, setHtml] = useState({
58
     widthHtml: autoWidthHtml0,
58
     widthHtml: autoWidthHtml0,
59
     heightHtml: autoHeightHtml0
59
     heightHtml: autoHeightHtml0
60
-  }));
60
+  });
61
   const changeSource = () =>
61
   const changeSource = () =>
62
     setHtml({
62
     setHtml({
63
       widthHtml: widthHtml === autoWidthHtml0 ? autoWidthHtml1 : autoWidthHtml0,
63
       widthHtml: widthHtml === autoWidthHtml0 ? autoWidthHtml1 : autoWidthHtml0,
64
       heightHtml: heightHtml === autoHeightHtml0 ? autoHeightHtml1 : autoHeightHtml0
64
       heightHtml: heightHtml === autoHeightHtml0 ? autoHeightHtml1 : autoHeightHtml0
65
     });
65
     });
66
 
66
 
67
-  const [{ widthStyle, heightStyle }, setStyle] = useState(() => ({
67
+  const [{ widthStyle, heightStyle }, setStyle] = useState({
68
     heightStyle: null,
68
     heightStyle: null,
69
     widthStyle: inlineBodyStyle
69
     widthStyle: inlineBodyStyle
70
-  }));
70
+  });
71
   const changeStyle = () =>
71
   const changeStyle = () =>
72
     setStyle({
72
     setStyle({
73
-      widthStyle: widthStyle == inlineBodyStyle ? style0 + inlineBodyStyle : inlineBodyStyle,
74
-      heightStyle: heightStyle == null ? style0 : null
73
+      widthStyle: widthStyle === inlineBodyStyle ? style0 + inlineBodyStyle : inlineBodyStyle,
74
+      heightStyle: heightStyle === null ? style0 : null
75
     });
75
     });
76
 
76
 
77
-  const [{ widthScript, heightScript }, setScript] = useState(() => ({
77
+  const [{ widthScript, heightScript }, setScript] = useState({
78
     heightScript: autoDetectLinkScript,
78
     heightScript: autoDetectLinkScript,
79
     widthScript: null
79
     widthScript: null
80
-  }));
80
+  });
81
   const changeScript = () =>
81
   const changeScript = () =>
82
     setScript({
82
     setScript({
83
-      widthScript: widthScript !== autoWidthScript ? autoWidthScript : null,
83
+      widthScript: widthScript == autoWidthScript ? autoWidthScript : null,
84
       heightScript:
84
       heightScript:
85
         heightScript !== autoDetectLinkScript ? autoDetectLinkScript : autoHeightScript + autoDetectLinkScript
85
         heightScript !== autoDetectLinkScript ? autoDetectLinkScript : autoHeightScript + autoDetectLinkScript
86
     });
86
     });
87
 
87
 
88
-  const [heightSize, setHeightSize] = useState(() => ({ height: 0, width: 0 }));
89
-  const [widthSize, setWidthSize] = useState(() => ({ height: 0, width: 0 }));
88
+  const [heightSize, setHeightSize] = useState({ height: 0, width: 0 });
89
+  const [widthSize, setWidthSize] = useState({ height: 0, width: 0 });
90
 
90
 
91
   return (
91
   return (
92
     <ScrollView
92
     <ScrollView