简体   繁体   English

如何清除 Redux 商店中的输入值?

[英]How to clear input value in Redux store?

When I press 'Enter' my function do somethin and then I have to clear input's value.. How to make it?当我按“Enter”时,我的 function 会做一些事情,然后我必须清除输入的值.. 怎么做?

Getting value from Redux store using this case:使用这种情况从 Redux 商店获取价值:

        case SEARCH_CITY: {
            return {
                ...state,
                cityValue: action.value
            }
        }

When you want to clear the input value, since you are getting the value from the redux store, you just have to call your redux action with an empty string from your function that gets called when you press enter.当您想清除输入值时,由于您从 redux 商店获取值,您只需使用 function 中的空字符串调用您的 redux 操作,当您按下回车键时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM