skip to Main Content

I have encounter a problem with my code. I just could not figure out how to put prop inside of a string so I can use in different jsx file. Here is the code:

const TypingGame = (props) => {
  const initialSentence = "banana"

I tried searing around the internet and using chatgpt but nothing worked out.

Thanks for feedback!

2

Answers


  1. your propobly useing the wrong code

    Login or Signup to reply.
  2. Fist thing to know that react use one-way-data flow so if you looking to send data from a parent component to a child using Props you can read it in this way

    const ParentComponent = ()=>{
     const sentence = "banana"
    return(
        <TypingGame sentence={senetence} />
    );
    }
    
    const TypingGame = (props) => {
      const initialSentence = props.sentence
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search