global-input-react
Advanced tools
Comparing version 4.3.4 to 4.3.5
@@ -15,4 +15,4 @@ "use strict"; | ||
* compare initData to expectedInitData | ||
* @param {*} initData | ||
* @param {*} expectedInitData | ||
* @param {*} initData | ||
* @param {*} expectedInitData | ||
*/ | ||
@@ -25,4 +25,2 @@ expect.extend({ | ||
initData: { | ||
action: "input", | ||
dataType: "form", | ||
form: { | ||
@@ -43,3 +41,3 @@ id: "test@globalinput.co.uk", | ||
receiver: testUtil.createInputReceivers(deviceConfig), | ||
//message receivers on the device side | ||
//message receivers on the device side | ||
ui: deviceConfig.initData, | ||
@@ -54,3 +52,3 @@ hook: (0, _reactHooks.renderHook)(() => (0, _index.useGlobalInputApp)(deviceConfig)) //calls the hook | ||
/** Here the device app displays a QR Code that contains the value of connectionCode, which is | ||
/** Here the device app displays a QR Code that contains the value of connectionCode, which is | ||
* an encrypted string containing information on how to connect to your device app | ||
@@ -57,0 +55,0 @@ **/ |
@@ -292,2 +292,7 @@ "use strict"; | ||
} = buildMessageHandlersForInitData(initDataConfigured, notify); | ||
if (!initData.action) { | ||
initData.action = 'input'; | ||
} | ||
setFieldProperties(fields, values, setters); | ||
@@ -303,5 +308,5 @@ mobileData.mobileConfig.initData = initData; | ||
const startConnect = (config, configId, notify) => { | ||
const startConnect = (config, notify) => { | ||
if (!isValidInitData(config.initData)) { | ||
console.log(" init-data-use-empty-" + configId); | ||
console.log(" init-data-use-empty-"); | ||
return; | ||
@@ -316,2 +321,7 @@ } | ||
} = buildMessageHandlersForInitData(config.initData, notify); | ||
if (!initData.action) { | ||
initData.action = 'input'; | ||
} | ||
mobileData.mobileConfig = buildMobileConfig(initData, config.options, notify); | ||
@@ -318,0 +328,0 @@ setFieldProperties(fields, values, setters); |
@@ -65,18 +65,16 @@ "use strict"; | ||
}, []); | ||
const configRef = (0, _react.useRef)(null); | ||
(0, _react.useEffect)(() => { | ||
if (typeof config === 'function') { | ||
config = config(); | ||
} | ||
if (typeof config === 'function') { | ||
config = config(); | ||
} | ||
if (typeof config.initData === 'function') { | ||
config.initData = config.initData(); | ||
} | ||
if (typeof config.initData === 'function') { | ||
config.initData = config.initData(); | ||
} | ||
configRef.current = config; | ||
globalInput.startConnect(config, notify); | ||
}, []); //You don't need to memoize the input parameter of this hook. | ||
const configRef = (0, _react.useRef)(config); | ||
configRef.current = config; | ||
const configId = config.initData && config.initData.id ? config.initData.id : ''; | ||
(0, _react.useEffect)(() => { | ||
globalInput.startConnect(configRef.current, configId, notify); | ||
}, [configId]); //You don't need to memoize the input parameter of this hook. | ||
const restart = (0, _react.useCallback)(config => { | ||
@@ -89,4 +87,4 @@ if (!attached.current) { | ||
globalInput.disconnect(notify); | ||
globalInput.startConnect(config ? config : configRef.current, configId, notify); | ||
}, [configId]); | ||
globalInput.startConnect(config ? config : configRef.current, notify); | ||
}, []); | ||
const sendInitData = (0, _react.useCallback)(initData => { | ||
@@ -93,0 +91,0 @@ if (!attached.current) { |
{ | ||
"name": "global-input-react", | ||
"version": "4.3.4", | ||
"version": "4.3.5", | ||
"description": "global input react component", | ||
@@ -72,5 +72,5 @@ "main": "./dist/index", | ||
"dependencies": { | ||
"global-input-message": "^2.1.1", | ||
"global-input-message": "^2.1.2", | ||
"qrcode.react": "^1.0.0" | ||
} | ||
} |
@@ -238,2 +238,5 @@ | ||
const { setters, fields, values, initData } = buildMessageHandlersForInitData(initDataConfigured, notify); | ||
if (!initData.action) { | ||
initData.action = 'input'; | ||
} | ||
setFieldProperties(fields, values, setters); | ||
@@ -245,9 +248,11 @@ mobileData.mobileConfig.initData = initData; | ||
export const startConnect = (config, configId, notify) => { | ||
export const startConnect = (config, notify) => { | ||
if (!isValidInitData(config.initData)) { | ||
console.log(" init-data-use-empty-" + configId); | ||
console.log(" init-data-use-empty-"); | ||
return; | ||
} | ||
const { setters, fields, values, initData } = buildMessageHandlersForInitData(config.initData, notify); | ||
if (!initData.action) { | ||
initData.action = 'input'; | ||
} | ||
mobileData.mobileConfig = buildMobileConfig(initData, config.options, notify); | ||
@@ -254,0 +259,0 @@ setFieldProperties(fields, values, setters); |
@@ -35,16 +35,13 @@ | ||
}, []); | ||
if (typeof config === 'function') { | ||
config = config(); | ||
} | ||
if (typeof config.initData === 'function') { | ||
config.initData = config.initData(); | ||
} | ||
const configRef = useRef(config); | ||
configRef.current = config; | ||
const configId = config.initData && config.initData.id ? config.initData.id : ''; | ||
const configRef = useRef(null); | ||
useEffect(() => { | ||
globalInput.startConnect(configRef.current, configId, notify); | ||
}, [configId]); //You don't need to memoize the input parameter of this hook. | ||
if (typeof config === 'function') { | ||
config = config(); | ||
} | ||
if (typeof config.initData === 'function') { | ||
config.initData = config.initData(); | ||
} | ||
configRef.current = config; | ||
globalInput.startConnect(config, notify); | ||
}, []); //You don't need to memoize the input parameter of this hook. | ||
@@ -57,4 +54,4 @@ const restart = useCallback((config) => { | ||
globalInput.disconnect(notify); | ||
globalInput.startConnect(config ? config : configRef.current, configId, notify); | ||
}, [configId]) | ||
globalInput.startConnect(config ? config : configRef.current, notify); | ||
}, []) | ||
@@ -61,0 +58,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1252247
37458
Updatedglobal-input-message@^2.1.2