【问题标题】:How to handle a checkbox event in react redux?react redux 如何处理复选框事件?
【发布时间】:2017-03-31 00:48:29
【问题描述】:

当用户选中复选框时,我必须重定向到另一个页面。 我是 react-redux 的新手。现在,我只知道处理提交 通过 dispatchaction 按钮,但我想知道如何处理 复选框动作?

    export default class myReportForm extends BaseForm {


            return(


                    </form>
                </div>        
        );

        }
    }

    Through handleSubmit in form, I could able to handle submit action. Can any one tell me how to handle checkbox . For example, when I ever click on Afloat , It should redirect me to another page or atleast some action should happen.

【问题讨论】:

  • @ZackTanner 被标记为不具建设性。
  • @lux 为什么?也许用户不知道这个 repo 的自述文件提供了它如何工作的视频解释。也许 OP 不知道这是一个连接两者的单独库。
  • @ZackTanner 你刚刚提供的内容对苦苦挣扎的用户来说比简单地粘贴链接有用得多。
  • @lux 这就是为什么它是评论,而不是答案。只是补充信息。

标签: reactjs checkbox react-redux


【解决方案1】:

mapStateToPropsmapDispatchToActions 是帮助函数,它们会将你的组件连接到 redux 存储。 mapStateToProps 将组件的属性链接到状态,mapDispatchToActions 将其事件链接到可以调度的操作。

http://redux.js.org/docs/basics/UsageWithReact.html#container-components

一如既往(我一直在推荐这个!)看看:

https://egghead.io/lessons/javascript-redux-generating-containers-with-connect-from-react-redux-visibletodolist(整个课程及其后续 - Idiomtic Redux - 很棒)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-27
    • 2014-02-01
    • 1970-01-01
    • 2020-10-11
    • 1970-01-01
    • 1970-01-01
    • 2014-12-29
    • 1970-01-01
    相关资源
    最近更新 更多