Code Explanation React - Pass an Array as Props

Tell us what’s happening:

I feel like this syntax is really important but what exactly is it doing?

I probably am wrong but I think that It is calling the tasks attribute from the HTML and we are converting it into a prop to be used in React? And I understand what .join() is, so I dont need an explanation there

const List = (props) => {
  { /* Change code below this line */ }
  return <p>{props.tasks.join(',')}</p>
  { /* Change code above this line */ }
};

Your code so far

const List = (props) => {
  { /* Change code below this line */ }
  return <p>{props.tasks.join(',')}</p>
  { /* Change code above this line */ }
};

class ToDo extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h1>To Do Lists</h1>
        <h2>Today</h2>
        { /* Change code below this line */ }
        <List tasks = {["walk dog", "workout", 'play']}/>
        <h2>Tomorrow</h2>
        <List tasks = {["walk dog", "workout", 'play']}/>
        { /* Change code above this line */ }
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

React - Pass an Array as Props

You’re giving a list to the ‘List’ component, and it shows that list on the screen with each item separated by a comma. Think of it like handing over a shopping list to be displayed in s shop window.

You’re giving a list to the ‘List’ component, and it shows that list on the screen with each item separated by a comma. Think of it like handing over a shopping list to be displayed in s shop window.

Have you tried this or not? If it does not work then inform me.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.