We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Connection with signalr

Thread ID:





146436 Aug 3,2019 09:35 AM UTC Aug 8,2019 03:12 AM UTC React - EJ 2 1
Tags: Toast
safronco safronco
Asked On August 3, 2019 09:35 AM UTC

Is there any exmaple for connection Syncfusion React Toast in order to get dynamic contents with signalr asp.net core?

Narayanasamy Panneer Selvam [Syncfusion]
Replied On August 8, 2019 03:12 AM UTC

Hi Safronco, 
Good day to you. 
By default, we cannot modify the content dynamically for existing displaying toasts. The dynamically changed content will be shown on notify the next toasts. So, we suggest you to hide the previous toast and show the next toast after setState. 
Please find the below code for your reference. 
constructor(props) { 
this.state = { 
    message: '', 
componentDidMount = () => { 
    const nick = window.prompt('Your name:', 'John'); 
    const hubConnection = new HubConnection('http://localhost:5000/chat'); 
    this.setState({ hubConnection, nick }, () => { 
        this.state.hubConnection.on('sendToAll', (nick, receivedMessage) => { 
            this.setState({ message: receivedMessage }); // Change the toast content using state 
            this.toastObj.hide(); // You can hide the toast 
            this.toastObj.show(); // You can show the toast 
create = () => { 
    this.toastObj.show({ timeOut: 0 }); 
<ToastComponent ref={ (toast) => { this.toastObj = toast; } } content = { this.state.message } id = 'toast_default' created = { this.create.bind(this) } > </ToastComponent> 
We have created sample for an ASP.NET core signalr with the react toast component. 
Please find the below steps to run the above sample. 
·       Navigate inside of AspNetCoreSignalR_React.Client folder and enter ‘npm install’. 
·       Start the client app by entering ‘npm start’. 
·       Run the AspNetCoreSignalR_React.Server project. 
If the above solution doesn’t meet your requirement, kindly send the below details. 
·       Have any reason on using static toasts with dynamic content update? 

Narayanasamy P. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon