4Geeks Coding Projects tutorials and exercises for people learning to code or improving their coding skills
Difficulty
beginnerRepository
Click to openVideo
Click to openLive demo
Not available
Average duration
4 hrs
Technologies
React improves the creation of custom components, which you can render throughout your web-app using the ReactDOM.render() method. A custom component allows you to divide and conquer, separating logical and visual challenges into smaller pieces- giving you greater control over the display and functionalities of each part of the web-app.
For example, to create a bootstrap <Card />
; component you'd code this:
1function Card(props){ 2 return ( 3 <div className="card"> 4 <img className="card-img-top" src="http://via.placeholder.com/350x150" alt="Card image cap" /> 5 <div className="card-body"> 6 <h5 className="card-title">Card title</h5> 7 <p className="card-text">Some quick example text to build on the card title and fill the card's content.</p> 8 <a href="#" className="btn btn-primary">Go somewhere</a> 9 </div> 10 </div> 11 ); 12}
After declaring it, you are able to import and use it in your webapp like this:
1//import react into the bundle 2import React from 'react'; 3import ReactDOM from 'react-dom'; 4import Card from './component/Card.jsx' 5 6ReactDOM.render(<Card />, document.querySelector('#root'));
Additionally, you can pass information through the Card component using props:
1 2<!-- Use of the custom component --> 3<Card imageUrl="http://via.placeholder.com/350x150" title="A nice image" /> 4
... for usage within the render method of your Card component (notice the image src and card title):
1//Declaration of custom component (Card.js) 2 3function Card(props){ 4 return ( 5 <div className="card"> 6 <img className="card-img-top" src={props.imageUrl} alt="Card image cap" /> 7 <div className="card-body"> 8 <h5 className="card-title">{props.title}</h5> 9 <p className="card-text">Some quick example text to build on the card title and fill the card's content.</p> 10 <a href="#" className="btn btn-primary">Go somewhere</a> 11 </div> 12 </div> 13 ); 14}
Do not clone this repository because we are going to be using a different template.
We recommend opening the react boilerplate
using a provisioning tool like Codespaces (recommended) or Gitpod. Alternatively, you can clone it on your local computer using the git clone
command.
This is the repository you need to open or clone:
https://github.com/4GeeksAcademy/react-hello
π Please follow these steps on how to start a coding project.
π‘ Important: Remember to save and upload your code to GitHub by creating a new repository, updating the remote (git remote set-url origin <your new url>
), and uploading the code to your new repository using the add
, commit
and push
commands from the git terminal.
Create a seconds-counter component, called SecondsCounter. It should look like this one.
1<SecondsCounter seconds={3434} />
This and many other projects are built by students as part of the 4Geeks Academy Coding Bootcamp by Alejandro Sanchez and many other contributors. Find out more about our Full Stack Developer Course, and Data Science Bootcamp.
4Geeks Coding Projects tutorials and exercises for people learning to code or improving their coding skills
Difficulty
beginnerRepository
Click to openVideo
Click to openLive demo
Not available
Average duration
4 hrs
Technologies