未捕获的类型错误:无法读取未定义的属性“主题”

时间:2021-06-16 14:36:50

标签: javascript reactjs mqtt

我有以下代码给出错误: “未捕获的类型错误:无法读取未定义的属性‘主题’”

查看代码:

import React from "react";

import { useSubscription } from "mqtt-react-hooks";

export default function Status() {
  const { message, topic } = useSubscription("bla-bla-bla");

  return (
    <div>
      <span style={{ fontSize: "3rem", fontWeight: "bold" }}>
        {`topic:${message.topic} - message: ${message.message}`}
      </span>
    </div>
  );
}

因为它是在span中声明和传递的。 我哪里错了?

0 个答案:

没有答案