question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PROBLEM - random string inserted to the page automatically

See original GitHub issue

Do you want to request a feature or report a bug? bug

What is the current behavior? getting random letters when activating toastify, number changing randomly everytime I call the toastify

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below: `class ThankYou extends Component {

render() {
    return (
      <React.Fragment>
            {toast.warn("We'll be in touch!")}
            <ToastContainer
                position="top-right"
                autoClose={3000}
                hideProgressBar
                // newestOnTop={false}
                closeOnClick
                rtl={false}
                pauseOnVisibilityChange
                draggable
                pauseOnHover/>
      </React.Fragment>
    );
}

}`

the code render is in another component with a simple state change toggle

What is the expected behavior? just a notification

screen shot 2019-01-07 at 21 59 51

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
fkhadracommented, Jan 7, 2019

Hello @dvash999,

You are calling js {toast.warn("We'll be in touch!")} inside the render method, toast return the toastId this is why you get the id rendered.

You should trigger the toast from an action. If you want to display the toast when the user click on the send button, you can do it as follow for example.

class MyComponent extends Component {

render() {
    return (
      <React.Fragment>
            <ToastContainer
                position="top-right"
                autoClose={3000}
                hideProgressBar
                // newestOnTop={false}
                closeOnClick
                rtl={false}
                pauseOnVisibilityChange
                draggable
                pauseOnHover/>
        <button onClick={() =>  toast.warn("We'll be in touch!"}>Send</button>
      </React.Fragment>
    );
}
1reaction
NishargShahcommented, May 20, 2020

Hello @dvash999,

You are calling js {toast.warn("We'll be in touch!")} inside the render method, toast return the toastId this is why you get the id rendered.

You should trigger the toast from an action. If you want to display the toast when the user click on the send button, you can do it as follow for example.

class MyComponent extends Component {

render() {
    return (
      <React.Fragment>
            <ToastContainer
                position="top-right"
                autoClose={3000}
                hideProgressBar
                // newestOnTop={false}
                closeOnClick
                rtl={false}
                pauseOnVisibilityChange
                draggable
                pauseOnHover/>
        <button onClick={() =>  toast.warn("We'll be in touch!"}>Send</button>
      </React.Fragment>
    );
}

I need to do with JS thing {toast.warn("We'll be in touch!")}. How can I achieve it without showing toastId?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random string HTML escape issue, when using special chars
It's really impossible to help you if your'e not showing the problematic code. I'm going to guess you're concatenating this random string into ......
Read more >
I have created a trigger, which generate's a random string ...
I have created a trigger, which generate's a random string, Please can any one help in writing the test class? · Normal test...
Read more >
Why does ASP.NET insert these random strings inside my html?
For instance, in my razor file I write this: @foreach(var item in Model){ Some data with @item } The html outputted…
Read more >
Too complicated code for generating a random string?
In particular I want to generate a random string of given letters, say std.ascii.letters. Anybody a simpler version than auto randomString ...
Read more >
Random String Generator using JavaScript - GeeksforGeeks
We can generate the random string in 2 ways ie., either we can iterate the loop for the specified length of the character...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found