Today, I am explaining you, if you are working in ReactJS so how to remove all spaces from string in ReactJS. in some custom requirement we need to remove spaces from string so we can use it. here, I will use string replace function for remove spaces from string.
Example :
import React from "react";
function Unity() {
var stringData = "Hi, Wel come to Web Developers India website's ReactJS post";
var newStringData = stringData.replace(/\s/g, "");
return (<><div id="wrapper" className="full-screen" style={{ background: "#ccc"}} ><div><p style={{ padding: "5px" }}><strong>Old String With Spaces: </strong>{stringData}</p><p style={{ padding: "5px" }}><strong>New String Without Spaces: </strong>{newStringData}</p></div></div> </>
);
}
export default Unity;
Output :
Hello, Welcome to webdeveloperindia.in. I am a full-stack web developer. Email – [email protected] | Skype – azaruddin23. I have knowledge of PHP, Laravel, Magento 1/2, Codeigniter, WordPress, Joomla, Shopify, Git, Bitbuket, jQuery, Ajax, Javascript and ReactJS.