Coding Challenge

Let’s solve a small coding challenge in React and Python while using Transcrypt.

We'll cover the following

Problem statement

Currently our application can add and remove text from within an HTML element.

Modify the react_hello.py and add two new buttons where one button turns the color of the displayed text to red, and another that turns the color of the displayed text to blue.

In the app() function, create a new React state variable to hold the current color value. Unlike before, we need to use CSS styling to set the text color. The HTML style attribute needs to be added as a property of the existing div element, with the CSS style color attribute set to the new color React state variable.

The last step is to create two functions to update the color state variable.

Get hands-on with 1200+ tech skills courses.