Giter Site home page Giter Site logo

redux-react-redux's Introduction

在redux.js中,直接执行,不要在判断了。就像点菜,后厨已经把菜上来了,才提要求,在点菜时就要想好。

这是一个纯函数

只要redux中的状态发生改变,这里就会被调用。React的原生状态改变了,setState会执行一次render,redux不会。

store.subscribe(()=>{
    // 重新渲染App,因为Diffing算法,只有改变的虚拟dom被重新渲染 
    ReactDOM.render(<App />,document.getElementById('root'));
})

每个组件有一个actioncreate和reducer,他们有一个共同的store大家长

以上action是对象的,都是同步action,异步action是一个函数,需要使用中间件redux-thunk

redux里面有个applyMiddleware,在createstore中传入redux-thunk中的thunk并作为第二个参数 createStore(countReducer,applyMiddleware(thunk)) displash过去在ActionCreators停了下来,然后再走store,Renders

  • 异步action中往往要开启一个同步action,以为异步到点了就要dispath了 store调的异步action,需要引入store,或者异步action函数传入一个displash,已经给我们准备好了

同步action都是对象,异步action都是函数,因为他要开启异步任务。一般不会用,没必要使用,但是面试可能会问

redux-react-redux's People

Contributors

yaahaha avatar

Watchers

 avatar

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.