Browse Source

lint example

Gaëtan Renaudeau 4 years ago
parent
commit
d527afcc92
No account linked to committer's email address
6 changed files with 13 additions and 10 deletions
  1. 2
    1
      example/src/ART.js
  2. 2
    4
      example/src/Canvas.js
  3. 1
    1
      example/src/Desc.js
  4. 1
    0
      example/src/FS.js
  5. 3
    2
      example/src/Transparency.js
  6. 4
    2
      example/src/Viewshoot.js

+ 2
- 1
example/src/ART.js View File

1
+/* eslint-disable react-native/no-inline-styles */
1
 //@flow
2
 //@flow
2
 import React, { useState, useCallback } from 'react';
3
 import React, { useState, useCallback } from 'react';
3
 import { SafeAreaView, Image, View } from 'react-native';
4
 import { SafeAreaView, Image, View } from 'react-native';
4
 import ViewShot from 'react-native-view-shot';
5
 import ViewShot from 'react-native-view-shot';
5
-import { Surface, Group, Shape, Path } from '@react-native-community/art';
6
+import { Surface, Group, Shape } from '@react-native-community/art';
6
 import Desc from './Desc';
7
 import Desc from './Desc';
7
 
8
 
8
 const dimension = { width: 300, height: 300 };
9
 const dimension = { width: 300, height: 300 };

+ 2
- 4
example/src/Canvas.js View File

1
 //@flow
1
 //@flow
2
 import React, { useRef, useState, useEffect, useCallback } from 'react';
2
 import React, { useRef, useState, useEffect, useCallback } from 'react';
3
-import { SafeAreaView, Image, View } from 'react-native';
3
+import { SafeAreaView, Image } from 'react-native';
4
 import ViewShot from 'react-native-view-shot';
4
 import ViewShot from 'react-native-view-shot';
5
-import { Surface, Group, Shape } from '@react-native-community/art';
6
-import Desc from './Desc';
7
 import Canvas from 'react-native-canvas';
5
 import Canvas from 'react-native-canvas';
8
 
6
 
9
 const dimension = { width: 300, height: 300 };
7
 const dimension = { width: 300, height: 300 };
20
     ctx.fillRect(140, 50, 60, 60);
18
     ctx.fillRect(140, 50, 60, 60);
21
     const timeout = setTimeout(onDrawn, 1000); // hack. react-native-canvas have no way to tell when it's executed
19
     const timeout = setTimeout(onDrawn, 1000); // hack. react-native-canvas have no way to tell when it's executed
22
     return () => clearTimeout(timeout);
20
     return () => clearTimeout(timeout);
23
-  }, []);
21
+  }, [onDrawn]);
24
   return <Canvas ref={ref} style={dimension} />;
22
   return <Canvas ref={ref} style={dimension} />;
25
 };
23
 };
26
 
24
 

+ 1
- 1
example/src/Desc.js View File

12
   },
12
   },
13
 });
13
 });
14
 
14
 
15
-const Desc = ({ desc }) => {
15
+const Desc = ({ desc }: { desc: string }) => {
16
   return <Text style={styles.desc}>{desc}</Text>;
16
   return <Text style={styles.desc}>{desc}</Text>;
17
 };
17
 };
18
 
18
 

+ 1
- 0
example/src/FS.js View File

1
+/* eslint-disable react-native/no-inline-styles */
1
 //@flow
2
 //@flow
2
 import React, { useState, useCallback } from 'react';
3
 import React, { useState, useCallback } from 'react';
3
 import { SafeAreaView, Image, View } from 'react-native';
4
 import { SafeAreaView, Image, View } from 'react-native';

+ 3
- 2
example/src/Transparency.js View File

1
+/* eslint-disable react-native/no-inline-styles */
1
 //@flow
2
 //@flow
2
-import React, { Component, useCallback, useState } from 'react';
3
-import { ScrollView, StyleSheet, Text, View, Button, Image } from 'react-native';
3
+import React, { useCallback, useState } from 'react';
4
+import { View, Image } from 'react-native';
4
 import ViewShot from 'react-native-view-shot';
5
 import ViewShot from 'react-native-view-shot';
5
 
6
 
6
 const Transparency = () => {
7
 const Transparency = () => {

+ 4
- 2
example/src/Viewshoot.js View File

83
     );
83
     );
84
   }
84
   }
85
 
85
 
86
+  full = React.createRef();
87
+
86
   captureViewShoot() {
88
   captureViewShoot() {
87
-    this.refs.full.capture().then(uri => {
89
+    this.full.current.capture().then(uri => {
88
       console.log('do something with ', uri);
90
       console.log('do something with ', uri);
89
       this.setState({ res: { uri: uri } });
91
       this.setState({ res: { uri: uri } });
90
     });
92
     });
94
     return (
96
     return (
95
       <ScrollView style={styles.container}>
97
       <ScrollView style={styles.container}>
96
         <ViewShot
98
         <ViewShot
97
-          ref="full"
99
+          ref={this.full}
98
           options={{ format: this.state.options.format, quality: this.state.options.quality }}
100
           options={{ format: this.state.options.format, quality: this.state.options.quality }}
99
           style={styles.container}
101
           style={styles.container}
100
         >
102
         >