Input sanitization in ReactJS

Shamnad P S picture Shamnad P S · Apr 24, 2017 · Viewed 16.2k times · Source

I am using ReactJS do develop a simple chat application. Could someone help me to sanitize the input . There is only one input text box to send chat messages. How to sanitize it?.

<input type="text"
              className="chat"
              value={this.state.name}
            />

Based on the documentations HTML escapes html by default. Is it enough?. Do I need to add any other sanitization methods. If yes, please let me know how to do that?.

Answer

dgrijuela picture dgrijuela · Apr 24, 2017

It's sanitized by default, you don't need a sanitization method unless you are using dangerouslySetInnerHTML which is not the case.