Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Using Props In React: Assigning CSS

function App() {
  return (
    <div className="App">
     <Test height="300px" width="300px" backgroundColor="blue">bbbb</Test>
	  
	     </div>
  );
}

export default App;


function Test({height, width, backgroundColor, children})
{
	
	const item = {height: height, width: width, backgroundColor: backgroundColor};
	 return(
	 	<>
		 <div style={item}>
		 
		 </div>
		 </>
	 )
}

/*height, width, backgroundColor (and children) are all props of Test component*/
 
PREVIOUS NEXT
Tagged: #Using #Props #In #Assigning #CSS
ADD COMMENT
Topic
Name
9+1 =