Skip to content

allfigueiredodev/advice-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Advice generator app solution

This is a solution to the Advice generator app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the app depending on their device's screen size
  • See hover states for all interactive elements on the page
  • Generate a new piece of advice by clicking the dice icon

Preview

Links

My process

Built with

  • Flexbox
  • Mobile-first workflow
  • React - JS library

What I learned

In this project I got the opportunity to use what I have been studying about React and put my skills to the test on how to work with function components, import and export them, writing markup with JSX, using JavaScript in JSX with curly braces, passing props to components and a little bit about hooks.

function ContentWrapper () {
    const [idResult, setIdResult] = useState('???');
    const [quoteResult, setQuoteResult] = useState ('???');
    
        async function fetchHandler () {
        const APIresponse = await fetch('https://api.adviceslip.com/advice');
        const data = await APIresponse.json();
        
        setIdResult(data.slip.id);
        setQuoteResult(data.slip.advice);
    } 

    return (
        <div className='content-wrapper'>
            <AdviceId advice={idResult} />
            <Quote quote={quoteResult} />
            <PatternDivider />
            <Botao onPress={fetchHandler}/>
        </div> 
    )
}

Continued development

There is a lot more about React that I need to tackle, such as hooks, adding interactivity and state management.

Useful resources

  • React: desenvolvendo com JavaScript - This was the course that gave me the base to develop this little advice generator.

    Alura is a Brazilian tech school that produces amazing content, so if Portuguese is your native language, go check it out.

  • ReactJS Documentation - The React documentation is very well written and their examples are the best it helped me a lot!

    At the end of every chapter, there is a challenge section where you can put your knowledge to the test and help reinforce what you have learned.

Author

Releases

No releases published

Packages

No packages published