Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
199 views
in Technique[技术] by (71.8m points)

javascript - 在Redux中处理jsx元素的click事件(Handling a click event of jsx element in redux)

I have the following initial state in the reducer:

(我在reducer中具有以下初始状态:)

const formatTypesDescriptions = [
    {
        title: 'Calendar',
        intro: <p>Calendar displays time <code>relative</code> to the <code>date picked</code>.
        <a onClick={() =>  console.log('Toggle Calendar') }>Click Here</a> to open the calendar</p>
    }
]


const initState = {
    formatTypesDescriptions,
    calendarIsVisible: false
}

const customVariables = (state = initState, action) => {
    switch (action.type) {
        case TOGGLE_CALENDAR_VISIBILITY:
            return {
                ...state,
                calendarIsVisible: !state.calendarIsVisible
            }
        default:
            return state
    }
}

I know it's an anti-pattern in redux to call an action from the reducer.

(我知道在redux中调用reducer的动作是一种反模式。)

My problem is that the descriptions may be localized in multiple languages, so i should add multiple objects of that description in multiple languages including a link.

(我的问题是,描述可能会以多种语言本地化,因此我应该以多种语言(包括链接)添加该描述的多个对象。)

How can i handle the event from the jsx element in the app's state?

(如何在应用程序状态下处理jsx元素中的事件?)

  ask by Ali Kleit translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...