Lädt...


🔧 Learning React: Function Components, JSX & Props


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Before you start reading just know that we're learning how function Components use JSX and props and not how JSX and Prop fully work. I'll talk more about what they do in later blogs when we know more about components but for now this is just for how their used in function components.

Function Components

Function components are components that return JSX and can turn it into a individual React Elements. Their used to render HTML into our website whenever needed. To add the running code (the code that'll be rendered) you'll need to use return followed by seperate parentheses. In the parentheses you'll put the markup code, and to call the function you'll use JSX markup < />.

const Welcome = () => {
return (<h1>Welcome two react part two!</h1>);
}
//Calling the function with JSX markup
root.render(<Welcome />);

JSX & Props

JSX is a Javascript syntax extension used to create or call a variable in between brackets to output its value, like the {age} in the example below. Their also mainly used for calling function components with the JSX markup < />. We can also make attributes for our components that change our variables value, we do this by using Props.

Props, short for properties, are used to access variables using JSX attributes. To use them in a function there should be a props parameter, next you make a variable that has the value of props. followed by the name of it. You can add props from different variables as well, but we mostly just make our own prop for our variable. Next we set the true value of the prop by making as JSX attribute of the variable (or prop) name.

For example, we made a variable called age that contained a prop about age. We called the prop into the return value using JSX syntax and then we set the value using a JSX attribute.

const Birthday = (props) => {
var age = props.age;
return (<h1>Congrats, you're now {age} years old!</h1>);
}
//Set the age's value with a JSX attribute and props
root.render(<Birthday age="19" />);
//It'll render the age JSX as 19 years old!


I'll talk more about props in my blog about class components. If you have any questions please comment them. Have a great day/night 👋.

...

🔧 Learning React: Function Components, JSX & Props


📈 75.55 Punkte
🔧 Programmierung

🔧 React Fundamentals – JSX, Components, and Props Explained


📈 56.84 Punkte
🔧 Programmierung

🔧 Evaluation metric, objective function, loss function, cost function, scoring function, error function


📈 50.1 Punkte
🔧 Programmierung

🔧 .js vs. .jsx: Should You Write Your React Code in .jsx?


📈 46.97 Punkte
🔧 Programmierung

🔧 React native tab view error :A props object containing a "key" prop is being spread into JSX


📈 46.3 Punkte
🔧 Programmierung

🔧 Dynamic Manipulation of Children in React JSX with React.cloneElement and React.Children.map


📈 40.42 Punkte
🔧 Programmierung

🔧 Converting couple thousands Js/Ts files that contains JSX content to jsx extension


📈 40.19 Punkte
🔧 Programmierung

🔧 How to render JSX to whatever you want with a custom JSX Renderer


📈 40.19 Punkte
🔧 Programmierung

🔧 React Components Explained: Function vs Class Components


📈 37.88 Punkte
🔧 Programmierung

🔧 React Components Explained: Function vs Class Components


📈 37.88 Punkte
🔧 Programmierung

🔧 React Components Explained: Function vs Class Components


📈 37.88 Punkte
🔧 Programmierung

🔧 Function Components vs Class Components in React – With Examples


📈 37.88 Punkte
🔧 Programmierung

🔧 React JSX for Beginners: How to Build Dynamic Components


📈 37.42 Punkte
🔧 Programmierung

🔧 React from 0 to Hero: Lesson 2 – Understanding Components, Props, and State


📈 36.74 Punkte
🔧 Programmierung

🔧 Understanding Props, Parent, and Child Components in React Native using TypeScript.


📈 36.74 Punkte
🔧 Programmierung

🔧 Handling React Warnings: Filtering Props in Styled Components


📈 36.74 Punkte
🔧 Programmierung

🔧 🌟 Components and Props in React.js 🌟


📈 36.74 Punkte
🔧 Programmierung

🔧 Typescript for React Components (or How To Write Components in React The Right Way)


📈 34.64 Punkte
🔧 Programmierung

🔧 Understanding Function Components vs Class Components in 100 seconds.


📈 31.11 Punkte
🔧 Programmierung

🔧 components/Courses /Courses.jsx


📈 30.64 Punkte
🔧 Programmierung

🔧 🚀 Day 3: JSX and Components


📈 30.64 Punkte
🔧 Programmierung

🔧 Passing Data to Child Components Without Props in Vue


📈 29.97 Punkte
🔧 Programmierung

🔧 Day 4: Components and Props - ReactJS


📈 29.97 Punkte
🔧 Programmierung

🔧 Why don't we pass child components as props?


📈 29.97 Punkte
🔧 Programmierung

🔧 Confused on +layout.js and +layout.svelte props passed in load() function...


📈 29.44 Punkte
🔧 Programmierung

🔧 A practical summary of React State variables & Props!


📈 28.53 Punkte
🔧 Programmierung

🔧 Embracing Modern React: Transitioning from Class Components to Functional Components


📈 27.86 Punkte
🔧 Programmierung

🔧 Embracing Modern React: Transitioning from Class Components to Functional Components


📈 27.86 Punkte
🔧 Programmierung

🔧 🔄 Class Components vs Functional Components: A Lifecycle Journey in React 🔄


📈 27.86 Punkte
🔧 Programmierung

🔧 Converting React Class Components to Functional Components: A Checklist and Example


📈 27.86 Punkte
🔧 Programmierung

🔧 React Components 101: Building Reusable Components


📈 27.86 Punkte
🔧 Programmierung

matomo