Skip to content

Commit 9a0be59

Browse files
author
Edward Xiao
committed
- check window type in message.ts
1 parent 376feab commit 9a0be59

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-inputs-validation",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"description": "a react inputs validation component",
55
"main": "index.js",
66
"repository": {

src/js/Inputs/message.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ declare global {
135135
}
136136
}
137137

138-
window.REACT_INPUTS_VALIDATION = window.REACT_INPUTS_VALIDATION || {};
138+
if (typeof window !== 'undefined') {
139+
window.REACT_INPUTS_VALIDATION = window.REACT_INPUTS_VALIDATION || {};
140+
}
139141

140142
// TODO: find a rewire way to handle non-export function
141143
export const handleCustomErrorMessage = (message: any, w: Window) => {
@@ -151,6 +153,8 @@ export const handleCustomErrorMessage = (message: any, w: Window) => {
151153
return res;
152154
};
153155

154-
message = handleCustomErrorMessage(message, window);
156+
if (typeof window !== 'undefined') {
157+
message = handleCustomErrorMessage(message, window);
158+
}
155159

156160
export default message;

0 commit comments

Comments
 (0)