Giter VIP home page Giter VIP logo

redux-initial-dispatch's People

Contributors

bal360 avatar emilycroft avatar ihollander avatar jeffkatzy avatar johnshelb avatar lukeghenco avatar maxwellbenton avatar nikymorg avatar sdcrouse avatar talum avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redux-initial-dispatch's Issues

Typo in one of the examples

In the code snippet:
dispatch({ type: '@@INIT' }) -> { counter: 0 } dispatch({type: 'INCREASE'}) -> { counter: 1 }

Should counter be count?

Solution branch does not pass the tests

I was having trouble getting the tests to execute successfully against my own code so on a whim I switched to the solution branch and ran the tests to see if the tests were just broken. While the tests finally executed successfully, the solution branch fails the tests with this logging:

  1. managePets reducer adds the pet when type is ADD_PET and the action has a payload property with the pet:

    Error: Expected { pets: [ { name: 'Splash', type: 'turtle', id: 100 }, undefined ] } to equal { pets: [ { name: 'Splash', type: 'turtle', id: 100 }, { name: 'avalanche', species: 'puppy', id: 101 } ] }

    • expected - actual

       "id": 100
       "name": "Splash"
       "type": "turtle"
      

      }

    • [undefined]
    • {
    •  "id": 101
      
    •  "name": "avalanche"
      
    •  "species": "puppy"
      
    • }
      ]
      }

    at assert (node_modules/expect/lib/assert.js:29:9)
    at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
    at Context. (test/index-test.js:14:107)
    at callFn (node_modules/mocha-nocache/lib/runnable.js:286:21)
    at Test.Runnable.run (node_modules/mocha-nocache/lib/runnable.js:279:7)
    at Runner.runTest (node_modules/mocha-nocache/lib/runner.js:421:10)
    at node_modules/mocha-nocache/lib/runner.js:528:12
    at next (node_modules/mocha-nocache/lib/runner.js:341:14)
    at node_modules/mocha-nocache/lib/runner.js:351:7
    at next (node_modules/mocha-nocache/lib/runner.js:283:14)
    at Immediate. (node_modules/mocha-nocache/lib/runner.js:319:5)

  2. managePets reducer removes the pet when action type is REMOVE_PET and the action has a payload property of the id of pet to be removed:

    Error: Expected { pets: [ { name: 'avalanche', species: 'puppy', id: 101 }, { name: 'sally', species: 'camel', id: 102 } ] } to equal { pets: [ { name: 'Splash', species: 'Turtle' }, { name: 'sally', species: 'camel', id: 102 } ] }

    • expected - actual

    {
    "pets": [
    {

    •  "id": 101
      
    •  "name": "avalanche"
      
    •  "species": "puppy"
      
    •  "name": "Splash"
      
    •  "species": "Turtle"
      
      }
      {
      "id": 102
      "name": "sally"

    at assert (node_modules/expect/lib/assert.js:29:9)
    at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
    at Context. (test/index-test.js:19:67)
    at callFn (node_modules/mocha-nocache/lib/runnable.js:286:21)
    at Test.Runnable.run (node_modules/mocha-nocache/lib/runnable.js:279:7)
    at Runner.runTest (node_modules/mocha-nocache/lib/runner.js:421:10)
    at node_modules/mocha-nocache/lib/runner.js:528:12
    at next (node_modules/mocha-nocache/lib/runner.js:341:14)
    at node_modules/mocha-nocache/lib/runner.js:351:7
    at next (node_modules/mocha-nocache/lib/runner.js:283:14)
    at Immediate. (node_modules/mocha-nocache/lib/runner.js:319:5)

  3. render displays the state on the html:
    TypeError: Cannot read property 'name' of undefined
    at src/reducers/managePets.js:37:19
    at Array.map (native)
    at render (src/reducers/managePets.js:36:29)
    at dispatch (src/reducers/managePets.js:31:3)
    at Context. (test/index-test.js:48:5)
    at callFn (node_modules/mocha-nocache/lib/runnable.js:286:21)
    at Test.Runnable.run (node_modules/mocha-nocache/lib/runnable.js:279:7)
    at Runner.runTest (node_modules/mocha-nocache/lib/runner.js:421:10)
    at node_modules/mocha-nocache/lib/runner.js:528:12
    at next (node_modules/mocha-nocache/lib/runner.js:341:14)
    at node_modules/mocha-nocache/lib/runner.js:351:7
    at next (node_modules/mocha-nocache/lib/runner.js:283:14)
    at Immediate. (node_modules/mocha-nocache/lib/runner.js:319:5)

  4. dispatch with render calls the render function which displays the updated html:
    TypeError: Cannot read property 'name' of undefined
    at src/reducers/managePets.js:37:19
    at Array.map (native)
    at render (src/reducers/managePets.js:36:29)
    at Object.dispatch (src/reducers/managePets.js:31:3)
    at Context. (test/index-test.js:63:13)
    at callFn (node_modules/mocha-nocache/lib/runnable.js:286:21)
    at Test.Runnable.run (node_modules/mocha-nocache/lib/runnable.js:279:7)
    at Runner.runTest (node_modules/mocha-nocache/lib/runner.js:421:10)
    at node_modules/mocha-nocache/lib/runner.js:528:12
    at next (node_modules/mocha-nocache/lib/runner.js:341:14)
    at node_modules/mocha-nocache/lib/runner.js:351:7
    at next (node_modules/mocha-nocache/lib/runner.js:283:14)
    at Immediate. (node_modules/mocha-nocache/lib/runner.js:319:5)

Seems like the solution branch should be passing the tests! I'm not sure if it's a problem with the solution or the tests.

Thanks!

npm start doesn't work for WSL students

found a work around by changing start alias in package.json to cmd.exe /C start <file>

i think there might be a better work around with xdg-open index.html instead but that requires adding a BROWSER var to .bashrc which i couldn't get to work

Incorrect Order for Arguments

Towards the end of the page there are two lines that say:

Action is defined because we passed { type: '@@init' } into dispatch. And the second argument, state, comes from the first line of our file. However, it's not defined.

State is always the first argument as far as I can tell, not the second. Not a big deal, just caused me to double-take and re-read things.

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.