Props, Parent and Child Element + How to ask React Questions on this Forum #24
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
First thing first. If you are practicing react js, start using Code Sandbox. https://www.youtube.com/watch?v=gANin2X_GnE Second thing, put this code in a "code sandbox" project, and let me know. Third Thing So, the idea in react is, it uses what is called as 'JSX". The fundamental concept is to treat "UI" as if they are functions. That means, you pass
React calls these parameters "props" for properties. Ultimately, they are nothing but variables that are passed. Returns values are nothing but VIEW things, like, what you are trying to show on the screen. which are ultimatley, DOM elements that are rendered by React. Now, instead of thinking these components as parent and child, a simple way to understand them is to go back to "function basics".
So, parent component is nothing but a function (calling function) that is calling the child (which is nothing but the called function). The main issue here is, you are trying to learn React without knowing the basics of JavaScipt, lol :P Don't do that. I have seen lot of developers try to do this. Especially students. I myself made this mistake. So, my big advice is to
And, finally, here is a simple example of props usage. https://codesandbox.io/s/react-hello-world-31-01-23-sl4d2m?file=/src/components/PassingObjects.js and also, you should spend more time studying this demo project that I created for React JS. It covers all basic concepts of beginner JS. https://codesandbox.io/s/react-hello-world-31-01-23-sl4d2m So, that is my long answer. More questions, let me know (but YOU HAVE TO PUT YOUR REACT CODE IN CODESANDBOX for future questions. Otherwise, I cannot help, he he :P ) Jay. |
Beta Was this translation helpful? Give feedback.
-
|
Here is a nice example from one of your classmates (or one of your edureka students) on the best way to ask questions. check it out. Thanks Jay. |
Beta Was this translation helpful? Give feedback.
-
|
Jay is expert in guiding the right things. After reading your answer thoroughly and checking some documentation of React has clarified my doubts. Now, with this knowledge i have made some experiment and created a carousal. With your loooong..... answer I have understood:
And after a 1hr reading and getting hands dirty I'm successfully created a carousal with react. Even though it's a very small thing I can enjoy as its my first thing. (rendering taking some time dont know the reason for the latency) Thank you so much Sir..! |
Beta Was this translation helpful? Give feedback.
@phani-sekhar
stop praising me so much, lol, he he :P but thank you for the kind words.
no issues, and happy to help.
As usual, when you get next doubt, just create a new Issue (if it is a coding problem) and new discussion (if its a theory general discussion).
Jay