polaryeti Posted December 29, 2022 Share Posted December 29, 2022 App.js: import React from 'react' import Helloworld from './components/HelloWorld'; import Users from "./components/Users"; const App = () => { return ( <div> <h1>List of Users</h1> <Users name="Zino Emi" job="Developer" /> <Users name="Lionel Messi" job="Web Developer" /> <Users name="Cristiano Ronaldo" job="Software Engineer" /> </div> ); }; export default App; src/components/Users.js: import React from 'react' const Users = (props) => { return ( <div> <div className="user"> <h2>Name: {props.name}</h2> <h3>Job:{props.job}</h3> </div> </div> ) } export default Users I'm not understanding the program flow here. What happens first then what? React is really confusing man. Can anyone help me build a mental model of it? Output: Quote Link to comment https://forums.phpfreaks.com/topic/315739-how-does-props-program-flow-work-in-react-js/ Share on other sites More sharing options...
polaryeti Posted December 29, 2022 Author Share Posted December 29, 2022 (edited) 1) Start with App.js 2) It returns Users component. 3) Inside Users component we pass properties name and job. 4) Inside Users.js we access it using props.name and props.job. A figure that helped me. Edited December 29, 2022 by polaryeti Quote Link to comment https://forums.phpfreaks.com/topic/315739-how-does-props-program-flow-work-in-react-js/#findComment-1604010 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.