0

I am using React to try and pull logos from a local file, but in order to do that, I need to pull the field from json data and convert it into a string.

So for example, I have <td width='60%'><Link to={item.id}>{item.id.toUpperCase()}</Link></td>

I know normal javascript won't really run here, so I can't try the JSON.stringify() function. I am new to react so please bear with me if I am asking super simple questions.

Also, is there a way to use javascript with react? I did some google searches and never received a clear-cut answer aside from using Babel.

3
  • 1
    javascript will work in react , where did you read the following statement I know normal javascript won't really run here? Commented Jan 22, 2018 at 6:43
  • It is really disappointing when someone is using react and don't know what actually it is and language/technology behind it. Commented Jan 22, 2018 at 6:50
  • Hey relax man I’m a noobie picking up something never had the chance of learning before.. trying to self teach is hard when there’s scattered resources. I guess I could have worded it better, javascript is turned into babel through a converter but not running js directly. Correct me if I’m wrong please, or don’t bother replying if you’ve got a smart ass comment Commented Jan 22, 2018 at 7:15

2 Answers 2

1

yes there is a way to use javascript with react we call it JSX.

for building sample react app you can do the following :

npm install -g create-react-app (-g installs it globally)
mkdir create-react-app myApp

then go inside the myApp directory and do

npm start

you can also refer https://reactjs.org/tutorial/tutorial.html#before-we-start

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, someone who has led me into the right direction. Appreciate the patience and kindness to a noobie genuinely trying to learn
1

Javascript will work.

I recommend you read into how JSX works

So, if you want to stringify text in <td>text</td>, you can just use

<td>{JSON.stringify(text)}</td> for example.

We might need more of your code, I'm not exactly sure what/where you're trying to parse to JSON.

1 Comment

So, the code is importing a json file and I’m using the value of field ID like student id and try to pull the image from a local file. But I can’t seem to figure out how to stringify the field I’m pulling to add a .png to it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.