From e444cf0119abb03e43b74c5fc356b74ef936ac90 Mon Sep 17 00:00:00 2001 From: Virginie Ky Date: Fri, 17 Jan 2020 17:20:27 +0100 Subject: [PATCH] events input ref --- .../admin/src/components/EventInput/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/strapi-admin/admin/src/components/EventInput/index.js b/packages/strapi-admin/admin/src/components/EventInput/index.js index f9db70a373..0d7fea6c53 100644 --- a/packages/strapi-admin/admin/src/components/EventInput/index.js +++ b/packages/strapi-admin/admin/src/components/EventInput/index.js @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useRef } from 'react'; import PropTypes from 'prop-types'; import { useGlobalContext } from 'strapi-helper-plugin'; @@ -12,10 +12,12 @@ const EventInput = ({ value: inputValue, }) => { const { formatMessage } = useGlobalContext(); + const onBlurRef = useRef(); + onBlurRef.current = onBlur; useEffect(() => { - onBlur({ target: { name, value: inputValue } }); - }, [inputValue, onBlur]); + onBlurRef.current(); + }, [onBlurRef, inputValue]); const headersName = [ formatMessage({ id: `Settings.webhooks.events.create` }), @@ -58,6 +60,7 @@ const EventInput = ({ onChange({ target: { name: inputName, value: Array.from(set) } }); }; + console.log('yoyo'); return ( @@ -99,4 +102,4 @@ EventInput.propTypes = { value: PropTypes.array, }; -export default EventInput; +export default React.memo(EventInput);