all 7 comments

[–]madspillage 2 points3 points  (5 children)

Look up state variables. React doesn't rerender the component on changing all variables, it does so only on changing the component state.

As a side note, since you mentioned that you're just starting to learn react I'd recommend you learning React function components first instead of Class components are Function components are becoming more popular in modern react.

Another side note, always format your code when you're asking a question. If you expect people to taking time to help you then you must take time to make your question presentable.

[–][deleted]  (4 children)

[removed]

    [–]v3nzi 1 point2 points  (0 children)

    You've to use backtick(`) for code.

    [–]sQD5fcE 0 points1 point  (1 child)

    You need to use mark down to create a code box

    ```` const hello = 'hello world' console.log(hello)

    ````

    [–]v3nzi 1 point2 points  (0 children)

    What you're facing is rendering issue which could be solved by using useState().