i am trying to make a new component inside a js variable

vivek modi

i am trying to make a new component inside a js variable. this is my code

class CourseSales extends Component {
    render(){
        var Course = this.props.items.map((item,i) => {
            return <Course name={item.name} price={item.price} key={i}/>
        });
       return(
           <div>
               <h1>Purchase your fav. course</h1>
               <p>{this.Course}</p>
           </div>
      );
   }
}

but its not showing result in the course component and console is giving me this error

React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
pizzarob

this.Course is undefined. Assigning a value to var Course does not automatically assign that value to this.Course. Saving the array to Course is not necessary. I would recommend the following:

class CourseSales extends Component {
    render(){
      return(
          <div>
              <h1>Purchase your fav. course</h1>
                {this.props.items.map((item,i) => (
                  <p key={i}>
                    <Course name={item.name} price={item.price} />
                  </p>
                )}
          </div>
      );
  }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I am trying to make a delete button on phonebook app with React js

I am trying to make a matrix of buttons in React.js

I am new to r. I am trying to make my code less complicated by using a for loop

I am new to javascript, and I am trying to make a html program to calculate dog age

I am using Vue.js 2.0 and I am trying to emit an event from `child component`

I am trying to add a new line to a list when I print it but I can't make it work

I am trying to make my bot make a new channel with the name of a guild, if it has not already been made

I am trying to make a GUI for a app I am working on but when I try print a global variable I get an error. Why?

I am trying to create a simple search, on click of a search button it should redirect to new component .but redirect is not at all working?

I am trying to install new component using npm. But it gives error

I am new to golang, I am trying to create a zip that must have a folder inside that is: tosend.zip/archivos/file.png

I am trying to created a nested for a child component

I am trying to make a struct that references a variable within itself. How do i do this?

i am new to react and i am trying to run a project it throws error static/js/bundle.js failed

Trying to make a discord bot direct message new members. What am I doing wrong?

Python - New to Python and I am trying to take a section of a list that is a string and make it a integer

Why am I getting the error "using uninitialized memory 'i'" and "uninitialized local variable 'i' used" when trying to make i = i*i

I am new to python and i am trying to create a leaderboard

I am trying to make a small tokenizer

I am trying to make a header collapse

i am trying to make a array of a object in php

I am trying to make a calculator, a simple one

I am trying to make a responsive nav bar

I am using DOS and I am trying to make the background white

I am trying to make a reusible component , select image and get binairy data back. Using that data in another component is where I am strigling

Trying to make a variable check something inside an array

I am new to JS and I am stuck when trying to bring the user back to the beginning of the program after user clicks OK in confirm

I am trying to change this React class component into a Functional Component

Vue.js- I am getting "this.cancelOrderFunction is not a function" error while calling method inside a child component

TOP Ranking

HotTag

Archive