Giter Club home page Giter Club logo

Comments (7)

jkeam avatar jkeam commented on June 18, 2024

I'd be happy to help.
First, let's start with your code snippet above:
loginRequest takes in two parameters loginRequest: ['username', 'password']

so your reducer should as well:
export const loginRequestReducer = (state, { username, password }) => {

That aside, how are you calling this? Is it something like:

const Item = ({ loading, login }) => {
  return (
    // some jsx here, calling the function on some button click or something: login('someone', 'password')
  )
}

const mapStateToProps = state => ({
  loading: state.foo.loading
})

const mapDispatchToProps = dispatch => ({
  login: (username, password) => dispatch(FooActions.loginRequest(username, password))
})

export default connect(mapStateToProps, mapDispatchToProps)(Item)

from reduxsauce.

jkeam avatar jkeam commented on June 18, 2024

Also your reducer, I would typically write like this:

export const loginRequestReducer = (state = INITIAL_STATE, { username, password }) => state.merge({
    loading: true,
    error: null
})

from reduxsauce.

Thembelani avatar Thembelani commented on June 18, 2024

Thanks @jkeam

It seems something about the way I persist the store is causing this issue. The methods from Immutable are available when the mobile app first runs but are removed when the app reloads.

from reduxsauce.

jkeam avatar jkeam commented on June 18, 2024

Ah. Would it help if I looked at your actual code? Do you have a github repo or something?

from reduxsauce.

jkeam avatar jkeam commented on June 18, 2024

@Thembelani Are you still encountering issues or can I close this issue?

from reduxsauce.

Thembelani avatar Thembelani commented on June 18, 2024

Thanks for the help @jkeam

from reduxsauce.

Snouzy avatar Snouzy commented on June 18, 2024

You can do something like this for your reducer to avoid the error state.merge is not a function.

export function reducer (state = INITIAL_STATE, action) {
    if (!Immutable.isImmutable(state)) {
        state = Immutable.from(state)
    }

    if (Types[action.type]) {
        return Types[action.type](state, action)
    }

    return state
}

from reduxsauce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.