Search code examples
javascriptreactjsflux

There is TypeError in flux whne try to create dispatcher


I try to import this class in index.js

import Dispatcher from "flux";
import React from "react";

export class CountdownDispatcher extends Dispatcher {
  handleAction(action) {
    console.log("dispatching action:", action);
    this.dispatch({
      source: "VIEW_ACTION",
      action
    });
  }
}

But reactjs compiler underline first raw with error message

Super expression must either be null or a function, not object

This is example from book React and redux page 186

Try to import in index.js like this:

import { CountDownDispatcher } from "./Flux/CountDownDispatcher";


Solution

  • import {Dispatcher} from "flux";