Learn how to approach your first ticket in the Labs project and understand the development workflow.
Learn best practices for implementing features in a React application and working with the project's codebase.
Understand how to interact with APIs, handle data fetching, and manage state in your React application.
// Example of fetching data from an API using axios import axios from 'axios'; import { useState, useEffect } from 'react'; function DataFetching() { const [data, setData] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchData = async () => { try { const response = await axios.get('https://api.example.com/data'); setData(response.data); setLoading(false); } catch (error) { setError(error.message); setLoading(false); } }; fetchData(); }, []); if (loading) return <div>Loading...</div>; if (error) return <div>Error: {error}</div>; return ( <div> {data.map(item => ( <div key={item.id}>{item.name}</div> ))} </div> ); }
Learn how to create well-designed, reusable components for your React application.
// Example of a reusable button component import React from 'react'; import PropTypes from 'prop-types'; import './Button.css'; const Button = ({ variant = 'primary', size = 'medium', disabled = false, children, onClick, ...props }) => { const classNames = `btn btn-${variant} btn-${size} ${disabled ? 'btn-disabled' : ''}`; return ( <button className={classNames} disabled={disabled} onClick={onClick} {...props} > {children} </button> ); }; Button.propTypes = { variant: PropTypes.oneOf(['primary', 'secondary', 'danger', 'success']), size: PropTypes.oneOf(['small', 'medium', 'large']), disabled: PropTypes.bool, children: PropTypes.node.isRequired, onClick: PropTypes.func }; export default Button;