Add data in React

Hello guys, i’m trying to learn React.jsx by making a project but i can’t upload data in the function section. I just wanna duplicate data with map function but it doesn’t work.
In the first screen you shall see, when i write “{props.item.title}” all components in my screen are melted away
image
this is the database


and this is the app.js with the map function

I did the tutorial from Scrimba in youtube and successfully make the airBnB clone. But i can’t realize what i doing wrong

Share your source code please

have a look at this so thread, should be useful javascript - Import JSON file in React - Stack Overflow good luck and happy learning :slight_smile:

Hey dude, thank you for the link, i was reading but i can’t find out where import my package.json and wicht name
image
this my options.

First off, please don’t share pictures of code - it makes it hard to help, try things out, quote things… Just cut and paste the code. Here is how:


When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

As I understand what you have here…

You have your data in your DataBase.js file. You import that into App.js and then map over it and pass it to Section.

I would check things as a I go. I would put

console.log('App.js - DataBase', DataBase)

in App.js, to confirm that it is loaded in propery. Put it before the function.

Then in Section.js, I would put:

console.log('Section.js - prop', props)

Put it on the line that you insert after the function declaration and before the return.

Do those and see what you are getting where.

1 Like

Okey,i already know the Backticks but i tought that it’d be better with screenshot. Sorry for that

That’s cool. Did you figure out your problem?

I just write the

console.log('App.js - DataBase', DataBase)

and start working magicly

Well, there was probably some other change you made there that caused something to work.

The most obvious problem in your original code is that Section doesn’t actually do anything with the props data.

The issue was that i write wron the data.js in the default `part

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