What I'm trying to do is that I want to add a line break between
remoteMessage.notification.title + remoteMessage.notification.body
title and body
If I use my code screen view show like this
this is my code
useEffect(() => {
const unsubscribe = messaging().onMessage(async (remoteMessage) => {
console.log(JSON.stringify(remoteMessage));
Alert.alert(
"A new FCM message arrived!",
JSON.stringify(
remoteMessage.notification.title + remoteMessage.notification.body
)
);
});
return unsubscribe;
}, []);
How can I fix my code? if I want to show like this?
title
body
You can use \n
and white-space: pre-line;
CSS:
const text = "Title\nBody"
function App() {
return <div className="pre-line">{text}</div>
}
ReactDOM.render(<App />, document.getElementById('root'))
.pre-line {
white-space: pre-line;
}
<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
<body>
<div id="root"></div>
</body>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With