@@ -31,8 +31,8 @@ function SignPad({
31
31
const [ isTab , setIsTab ] = useState ( "draw" ) ;
32
32
const [ isSignImg , setIsSignImg ] = useState ( "" ) ;
33
33
const [ signValue , setSignValue ] = useState ( "" ) ;
34
- const [ textWidth , setTextWidth ] = useState ( null ) ;
35
- const [ textHeight , setTextHeight ] = useState ( null ) ;
34
+ const [ textWidth , setTextWidth ] = useState ( 0 ) ;
35
+ const [ textHeight , setTextHeight ] = useState ( 0 ) ;
36
36
const [ signatureType , setSignatureType ] = useState ( "draw" ) ;
37
37
const fontOptions = [
38
38
{ value : "Fasthand" } ,
@@ -51,7 +51,7 @@ function SignPad({
51
51
`Parse/${ localStorage . getItem ( "parseAppId" ) } /currentUser`
52
52
) ;
53
53
const jsonSender = JSON . parse ( senderUser ) ;
54
- const currentUserName = jsonSender && jsonSender . name ;
54
+ const currentUserName = jsonSender && jsonSender ? .name ;
55
55
56
56
//function for clear signature image
57
57
const handleClear = ( ) => {
@@ -137,7 +137,7 @@ function SignPad({
137
137
( isTab === "draw" && isSignImg ) ||
138
138
( isTab === "image" && image ) ||
139
139
( isTab === "mysignature" && isDefaultSign ) ||
140
- ( isTab === "type" && textWidth )
140
+ ( isTab === "type" && signValue )
141
141
? false
142
142
: image
143
143
? false
@@ -169,10 +169,10 @@ function SignPad({
169
169
}
170
170
}
171
171
172
- const trimmedName = currentUserName && currentUserName . trim ( ) ;
172
+ const trimmedName = currentUserName && currentUserName ? .trim ( ) ;
173
173
const firstCharacter = trimmedName ?. charAt ( 0 ) ;
174
174
const userName = isInitial ? firstCharacter : currentUserName ;
175
- setSignValue ( userName ) ;
175
+ setSignValue ( userName || "" ) ;
176
176
setFontSelect ( "Fasthand" ) ;
177
177
178
178
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -200,8 +200,10 @@ function SignPad({
200
200
canvasRef . current . fromDataURL ( isSignImg ) ;
201
201
}
202
202
if ( isTab === "type" ) {
203
- const trimmedName = signValue ? signValue . trim ( ) : currentUserName . trim ( ) ;
204
- const firstCharacter = trimmedName . charAt ( 0 ) ;
203
+ const trimmedName = signValue
204
+ ? signValue ?. trim ( )
205
+ : currentUserName ?. trim ( ) ;
206
+ const firstCharacter = trimmedName ?. charAt ( 0 ) ;
205
207
const userName = isInitial ? firstCharacter : signValue ;
206
208
setSignValue ( userName ) ;
207
209
convertToImg ( fontSelect , userName ) ;
0 commit comments