react-hook-core 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/useMessage.ts CHANGED
@@ -1,37 +1,37 @@
1
- import * as React from 'react';
1
+ import * as React from "react"
2
2
 
3
3
  interface ErrorMessage {
4
- field: string;
5
- code: string;
6
- param?: string|number|Date;
7
- message?: string;
4
+ field: string
5
+ code: string
6
+ param?: string | number | Date
7
+ message?: string
8
8
  }
9
9
 
10
10
  export interface MessageState {
11
- message?: string;
12
- alertClass?: string;
11
+ message?: string
12
+ alertClass?: string
13
13
  }
14
14
 
15
15
  export const useMessage = (initialState: MessageState) => {
16
- const [msg, setMessage] = React.useState<MessageState>(initialState);
16
+ const [msg, setMessage] = React.useState<MessageState>(initialState)
17
17
 
18
18
  const hideMessage = () => {
19
- setMessage({alertClass: '', message: ''});
20
- };
19
+ setMessage({ alertClass: "", message: "" })
20
+ }
21
21
 
22
22
  const showMessage = (ms: string) => {
23
- setMessage({alertClass: 'alert alert-info', message: ms});
24
- };
23
+ setMessage({ alertClass: "alert alert-info", message: ms })
24
+ }
25
25
 
26
- const showError = (ms: string|ErrorMessage[]) => {
27
- if (typeof ms === 'string') {
28
- setMessage({alertClass: 'alert alert-error', message: ms});
26
+ const showError = (ms: string | ErrorMessage[]) => {
27
+ if (typeof ms === "string") {
28
+ setMessage({ alertClass: "alert alert-error", message: ms })
29
29
  } else if (Array.isArray(ms) && ms.length > 0) {
30
- setMessage({alertClass: 'alert alert-error', message: ms[0].message});
30
+ setMessage({ alertClass: "alert alert-error", message: ms[0].message })
31
31
  } else {
32
- const x = JSON.stringify(ms);
33
- setMessage({alertClass: 'alert alert-error', message: x});
32
+ const x = JSON.stringify(ms)
33
+ setMessage({ alertClass: "alert alert-error", message: x })
34
34
  }
35
- };
36
- return {msg, showError, showMessage, hideMessage};
37
- };
35
+ }
36
+ return { msg, showError, showMessage, hideMessage }
37
+ }