mdx-deck build error with 'TypeError: Cannot read property 'update' of null'

Created on 31 Aug 2018  Â·  7Comments  Â·  Source: jxnblk/mdx-deck

  "devDependencies": {
    "mdx-deck": "^1.7.1",
    "mdx-deck-code-surfer": "^0.4.0",
    "raw-loader": "^0.5.1"
  }

npm start is ok, but when I build it into bundle, an error is thrown:

[mdx-deck] building
[mdx-deck] rendering static html
[err] TypeError: Cannot read property 'update' of null
    at new InnerCodeSurfer (/Users/zhiqiangzhong/Zz/myProject/slides/node_modules/mdx-deck-code-surfer/dist/deck-code-surfer.js:60:30)
    at processChild (/Users/zhiqiangzhong/Zz/myProject/slides/node_modules/react-dom/cjs/react-dom-server.node.development.js:2098:14)
    at resolve (/Users/zhiqiangzhong/Zz/myProject/slides/node_modules/react-dom/cjs/react-dom-server.node.development.js:2064:5)
    at ReactDOMServerRenderer.render (/Users/zhiqiangzhong/Zz/myProject/slides/node_modules/react-dom/cjs/react-dom-server.node.development.js:2383:22)
......

It doesn't look like my fault

Most helpful comment

I fixed it by method provided in this issue by adding --no-html option to build command, it seems an issue which will be fixed in next release.

All 7 comments

Related #119

@jxnblk Appear is not used in my slide, here is the code cause error:

import React from 'react';
import { CodeSurfer } from "mdx-deck-code-surfer";
import oceanicNext from "prism-react-renderer/themes/oceanicNext";

export default class FSM extends React.Component {
  render() {
    return (
      <CodeSurfer
        title="Demo"
        theme={oceanicNext}
        code={require("!raw-loader!../snippets/fsm.js")}
        lang="javascript"
        showNumbers={false}
        dark={false}
        steps={[]}
      />
    );
  }
}

it seems that CodeSurfer is not read property update of deck.

I fixed it by method provided in this issue by adding --no-html option to build command, it seems an issue which will be fixed in next release.

Does this issue still occur with the latest version and without using CodeSurfer? There might be an issue with how it's reading context from mdx-deck's state

@jxnblk slide building is success with the latest version and without using CodeSurfer.
According to "TypeError: Cannot read property 'update' of null", below is the code snippet that throw the error:

var InnerCodeSurfer = function (_React$Component) {
  _inherits(InnerCodeSurfer, _React$Component);

  function InnerCodeSurfer(props) {
    _classCallCheck(this, InnerCodeSurfer);

    var _this = _possibleConstructorReturn(this, (InnerCodeSurfer.__proto__ || Object.getPrototypeOf(InnerCodeSurfer)).call(this, props));

    var _props$deck = props.deck,
        update = _props$deck.update,
        index = _props$deck.index;

    var steps = props.steps ? props.steps.length : 0;
    update(_mdxDeck.updaters.setSteps(index, steps));
    return _this;
  }

which indicates that props.deck can’t be read.

this comment did the trick for me: https://github.com/pomber/code-surfer/issues/8#issuecomment-416373549

Closing this since the internals for v2 are quite different now – please open a new issue if anything like this persists with v2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janhesters picture janhesters  Â·  3Comments

codepunkt picture codepunkt  Â·  5Comments

jxnblk picture jxnblk  Â·  4Comments

wgao19 picture wgao19  Â·  7Comments

Irev-Dev picture Irev-Dev  Â·  4Comments