I need to format a text inside a variable using React. I need to use n or but it’s not working, Also I need to bold the tittles. For example: const termsAndConditions = “Terms and Conditions Welcome to Website Name! These terms and conditions outline the rules and regulations for the use of Compan…
Tag: reactjs
React Firebase app auth service does not work in production
I have set up a React authorization through the Google account on my web app, that does not really work in production, however, works on the localhost. Here is the message from the dev mode (that perhaps may impact): The issue is that the google sign-in modal instantly disappears from the screen! What may be …
Why use history.push or some other method from react-router-dom instead of just assigning the path to window.location.pathname?
It seems easier to me when I need to navigate somewhere in my code to just assign the path where I want to go to window.location.pathname. Is there any disadvantage to doing this? Answer Because window.location.pathname triggers a reload, defeating the entire purpose of react-router, while history.push() just…
How to increment the filename if file already exists in javascript
I have implemented Drag and Drop File Upload in my react project, so on every drag and drop of file into the drop zone , I’m taking the file and accessing it’s name and it’s data and converting the data to base64 using javscript’s FileReader() and readAsDataURL() and updating the state…
When do I must use the spread operator in useReducer?
I’ve noticed that in many useReducer examples, the spread operator is used in the reducer like this: However in many of my practices, I removed …state and had no issues at all. I understand that …state is used to preserve the state of the remaining states, but would a reducer preserve those …
How to time duration calculate in react js
I want to calculate the time duration with the current time and another time. In my problem the current time and all ready time in data base time format are different, this format is given format: 2020-11-07 , 22:52 but now time format is 30/10/2020 , 20:50:34 . So I have a problem with this diffrent format. …
customise color picker with out any package in react
picture here is the design can we able to implement color picker like this without any packages in react is it possible to customize a color picker like the above image with react(without any package)? I tried a lot, but cannot able to find the proper solution. if anyone can help thanks in advance. click this…
Is there a way to create a dynamic state and setState in React
I have the following deceleration: const [open1, setOpen1] = useState(false); and would like to generate this as many as I fetch records from the database (for every record fetched ) I need new [open, setopen] here is my for loop used in my code. Answer Create separate component to hold ‘open’ sta…
Save a prop when moving away and coming back to page ReactJS
I have a username property that I have passed on from “log in” route to “product list” route using I then have a <Link to={‘/products/${product.id}’}>More info</Link> that sends me from “product list” to an “individual product”. When I th…
Warning console : Each child in a list should have a unique “key” prop in table in code react.js
I want to correct the warning “Each child in a list should have a unique” key “prop” in the console. I tried adding the props “rowkey”, “key” in the but the problem still exists. Here is the warning on the console:: Answer You need to add ‘key’ prop …