Open kitar-kks opened 2 years ago
Just try {topic:${message?.topic} - message: ${message?.message}} It will print : "topic: undefined - message: undefined" if your message object is empty and it's going to be re-rendered each time a message arrive without error
I got a error from use Subscription example ( TypeError: Cannot read properties of undefined (reading 'topic') )
`import React from 'react';
import { useSubscription } from 'mqtt-react-hooks';
export default function Status() { /* Message structure:
message: string */ const { message } = useSubscription([ 'room/esp32/testing', 'room/esp32/light', ]);
return ( <> <div style={{ display: 'flex', flexDirection: 'column' }}> {
topic:${message.topic} - message: ${message.message}
}