1.0.4 • Published 3 years ago

azure-reactjs-iot-hub-receiver v1.0.4

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

Getting Started with Create React App

This project was bootstrapped with Create React App.

Install Component

npm install azure-reactjs-iot-hub-receiver

or

npm add azure-reactjs-iot-hub-receiver

Azure Credentials:

Setup Component:

// Import the component
import IotReciever from "azure-reactjs-iot-hub-receiver/dist/iotreceiver"
...

class App extends React.Component {
constructor(props) {
    super(props)
    // Setup the state variable to storage the received messages from IoT devices
    this.state = {
    example: ""
    }
}

// Setup the callback to receive messages from IoT devices

callbackFunction = (childData) => {
    console.log(childData)
    this.setState({
    example: childData
    })
}

render(){
    return (
    <div className="App">
        {// Setup the component props}
        <IotReciever
            callback={this.callbackFunction}
            eventHubConsumerGroup={"ConsumerGroupIoT"}
            eventHubEndpoint={"Endpoint=sb://xxxxxxx"}
        />
        {
        //.......
        }
    </div>
    );
}

}

export default App