score:1
Accepted answer
you can do that using regular expressions.
first, replace line breaks with '\n' in your textarea
value.
inputvalue.replace(/\n/g, "\\n");
now send this new value to firestore.
to display the value again reverse the procedure.
receivedvalue.replace(/\\n/g, "\n");
score:0
adding to the above answer. if you have something with "return keys" even in your state you would need to add
<div style = {{ whitespace: 'pre-line'}}
this template literal is needed for you to have the return keys in your html. otherwise, they will automatically be replaced with spaces.
Source: stackoverflow.com
Related Query
- Firebase Firestore not reciving enters/ returns in the database, with material ui and react
- Displaying users individual data with firebase firestore + react with UID as oppose to the whole database
- react firebase custom fields authentication create user is not storing the custom fields in firestore database collection
- Redux Store does not update state with created data on firebase real-time database
- cleanup() not working in useEffect() with Firebase Firestore onSnapshot
- Reactjs dropzone not uploading all dragged and dropped files to firebase firestore database in reactjs
- Axios with firebase does not return the data while putting it
- How to fetch all the documents with unique id from firestore database using React?
- React with firebase cloud firestore- presenting data from the database
- Firebase with React - unable to delete items from the database
- Why am I not able to set my state using useState and send the state to firebase realtime database at the same time?
- Functions within the loop do not work with data from the database
- i am trying to store the photo in the database (firebase) and in the storage. the photo got store in the Storage, but not added in the firestore
- "Failed to get document because the client is offline" Firebase error with the firestore emulator
- Why is Cloud Firestore not allowing access with Firebase Auth validation?
- Data obtained from Firebase Realtime Database in React Native using Hooks is not displayed on the screen
- Hi I am trying to add the material ui Iconbutton with input ref to upload the image its not working
- React material UI autocomplete is not working with the formik
- Props values in react router render method are not updated with Firebase firestore onsnapshot realtime update
- Firebase firestore not creating doc with recently created uid
- not getting string from the firebase database
- Why is the user not persisted on a page refresh with Firebase and Firebase React Hooks?
- My download URL in my firebase storage is not transferring to the database
- Is there some way in firebase firestore to block the user from signing in with the same email or gmail account?
- How to get the ID and not the Generated Key from Firebase Realtime Database in React?
- How to dynamically switch between firebase and firestore as the database and dispatch redux actions accordingly
- Getting an error "A non-serializable value was detected in the state" when using redux toolkit - but NOT with normal redux
- In Firebase when using push() How do I get the unique ID and store in my database
- 'npm start' returns error: "There might be a problem with the project dependency tree"
- How do I use the Firebase onAuthStateChange with the new React Hooks?
More Query from same tag
- Cant use a useDispatch inside a useEffect
- React Reuse Fetch JSON data throughout components
- Map two seperate array objects into one
- How to add Validations to my Input Field in React JS
- How can I remove last shape layer when creating new one in lefalet
- How to Change a css property based on a state of another component
- How do you dynamically update a key-value pair on a typed object in TypeScript
- How to open a page in new tab on click of a button in react? I want to send some data to that page also
- React Router showing No route matches path even though route exists
- Redirect BACK from cloud functions to Firebase Hosting?
- Prop sharing between components
- Cant dynamically update the React app using component
- Display rows with current date as top result using react-table
- Contact Form with ReactJS don't sends data to firebase
- is there any benefit of using useCallback without React.memo?
- ReferenceError: provided is not defined
- Typescript Constructor Parameters. Parsing error: Unexpected reserved word 'public'
- Change color of font-awesome icons with React
- React/Redux - how can I make a copy of deeply nested state?
- Yup + useFormik - conditional required field based on some parameter
- How to create a new user along with their profile images in Sanity?
- Uncaught (in promise) Error: Request failed with status code 400 at createError (createError.js:16) at settle at XMLHttpRequest.onloadend
- External Vendor Scripts( JS, Jquery) Not working after render in ReactJS
- Styling background (fill) with ChartJs and React
- Test login component with react hooks,
- mini-css-extract plugin with postcss throws this.getOptions is not a function
- React - Navigation Prompt onConfirm gets triggered straight away
- table-hover (bootstrap) not work with react
- Error: Component definition is missing display name react/display-name with React.forwardRef
- Removing black border from material-ui button