looking for some solutions? You are welcome.

SOLVED: Knowing Redux in React

abu abu:

My reducer is like below

const reducer = (state = initialState, action) => {
    switch (action.type) {
        case 'Hello': {
        default: return state

I would like to separate action from reducer. I would like to import it into reducer from another file. How can I do that ?

Another Question

I have a submit button like below.

<div onClick={this.handleSubmit}>Submit</div>

I am calling below function when submit button clicked.

handleSubmit = event => {
    this.props.dispatch( { type: 'Hello' } );

What is type here ? Why should I use it ? What is it doing inside reducer/actions ?

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: