How to switch copy mode between text and html with React

25 Views Asked by At

I want to implement the input form which can be switched between plain text and html mode by users with React. However I have no idea how to do this. Please give me some hints e.g. sample code.

Thank you.

1

There are 1 best solutions below

0
On

You have multiple choices based on your desire !

  1. If plain text and html mode styles are completely different, you can create two separate components and trigger which one to show by a simple useState()
  2. If you just want to disable the html input in plain text mode , you can disable the input and give it your own style, you should again set the disabled props equal to a boolean state and trigger that state by a button