i am trying to add a button to the end of props.text but using this code puts [object Object] to the end of the text instead of the "set lines" button
function UnchangedText(props) {
const setLines = <button>Set Lines</button>;
return (
<div className={props.className}>
<span></span>
<pre>{
props.text.includes("\\n")
? props.text setLines
: props.text
}</pre>
</div>
);
}
CodePudding user response:
try this
function UnchangedText(props) {
const setLines = <button>Set Lines</button>;
return (
<div className={props.className}>
<span></span>
<pre>{
props.text.includes("\\n")
? <>{props.text} {setLines} </>
: props.text
}</pre>
</div>
);
}