Git Product home page Git Product logo

Comments (10)

Beace avatar Beace commented on May 1, 2024 1

I found the problem and it was a problem with the react-boilerplate. I cloned the latest react-boilerplate directly and found that mapStateToProps did indeed execute twice.

from react-boilerplate-typescript.

Can-Sahin avatar Can-Sahin commented on May 1, 2024

what is the issue ? I couldnt understand. But to explain that line of code, state can return undefined and state.home is causing a crash in that case. So if there is no state shouldn't we use initalState ?

from react-boilerplate-typescript.

Beace avatar Beace commented on May 1, 2024

If I do not use reselect, I have to do this in mapStateToProps.

const mapStateToProps = (state) => {
  return {
    data: state.home ? state.home.data : initialState.data,
    userinfo: state.home ? state.home.userinfo : initialState.userinfo,
    ...
  };
};

from react-boilerplate-typescript.

Beace avatar Beace commented on May 1, 2024

Sorry for that, Is there a simple way to get the initialState directly?

from react-boilerplate-typescript.

Can-Sahin avatar Can-Sahin commented on May 1, 2024

Still unclear. If you dont use reselect then you have to destruct state into your objects of course.

why not like this ?

const mapStateToProps = (state) => {
  const homeState = state ? state.home || initialState  : initialState;
  return {
    data: homeState.data,
    userinfo: homeState.userinfo,
    ...
  };
};

from react-boilerplate-typescript.

Beace avatar Beace commented on May 1, 2024

I already know the reason for this problem. Thank you for your reply. I just wonder why render method was executed twice after injecting reducer.Is it because there is no initialization?

const withReducer = injectReducer({ key: 'certificate', reducer: reducer });
const withSaga = injectSaga({ key: 'certificate', saga: saga });

image

from react-boilerplate-typescript.

Can-Sahin avatar Can-Sahin commented on May 1, 2024

hmm which of the things you said about is problem. Can you explain very simply. Because so far you asked

  • How can I inject reducer after render
  • Is there a simple way to get the initialState directly?
  • Not using reselect

all these are seperate things. I dont understand what the problem is ? or is this a question? When you run the boilerplate code render isn't executed twice. So i have no idea how to reproduce. Or what to reproduce.

from react-boilerplate-typescript.

Beace avatar Beace commented on May 1, 2024

I'm sorry to trouble you, but I refer to the latest react-boilerplate and react-boilerplate-typescript. I put these two together, partly dependent on versions that are inconsistent. It may be my personal problem. I'll debug it again.Thank you again for your reply.

from react-boilerplate-typescript.

Can-Sahin avatar Can-Sahin commented on May 1, 2024

Ohh react-boilerplate relased a new version a week ago 4.0.0. Mine is still 3.7.0. I'm gonna update repo too soon. So the latest version are not the same.

from react-boilerplate-typescript.

Beace avatar Beace commented on May 1, 2024

When I find the problem, I may be able to contribute a pr.

from react-boilerplate-typescript.

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.