Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 2 years ago

Responsive newsletter subscribe form using Typescript, Vite, & React

react, typescript, vite, react-router
Christopher Castaneda•90
@chrisdcast
A solution to the Newsletter sign-up form with success message challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Initial Thoughts

This challenge definitely took longer than usual. I wanted to practice using React and this was my first project built with Typescript so there was a lot of tooling and learning and reading docs. I probably could have built it in a 10th of the time with vanilla HTML/CSS/JS but I'm glad I took the time to learn it.

Challenges

  • Using the react-router-dom package was only a little confusing because some of the docs recommended using createBrowserRouter and others recommended wrapping Route components in a parent BrowserRouter component. Getting past that I was able to get things running smoothly.
  • Using react-hook-form was a little weird. React with all of it's support makes sure you get in the mindset of doing things 'the React way' with controlled inputs on all your text fields, but that's not how this package works by default. It encourages you to use uncontrolled raw html form components and it felt kind of wrong.
  • Typescript syntax was a little tricky at first, but I'm getting more used to it. I am a little confused why the handbook recommends not explicitly typing everything but I'm sure it's something that's up to personal taste.

Things to Improve

  • I still need some practice and guidance on how to organize my react project and where to put my various components.
  • I also need better judgement on when to separate various elements into different components or just build them as one block of html.

Questions

  • If anyone has any insight on how a react app files are typically structured I'd love to hear it.
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Hassan•940
    @hnasser44
    Posted almost 2 years ago

    Hello, a typical React project follows a folder structure that helps to keep things organized. A common structure is:

    src/
      |- components/
      |- pages/
      |- utils/
      |- assets/
      |- App.js
      |- index.js
      |- index.css
    

    components: This folder contains reusable components that can be used across different pages.

    pages: Each page of your application should have its own folder here, containing the components specific to that page.

    utils: Utility functions or helper functions can be placed in this folder.

    assets: Images, fonts, or other static assets can be stored here.

    Component Separation: When deciding whether to separate elements into different components or keep them as one block, consider the reusability and complexity of the component.

    Reusability: If an element is used in multiple places or has the potential to be reused, it's better to create a separate component. This follows the DRY (Don't Repeat Yourself) principle, making your code easier to maintain and reducing duplication.

    Complexity: If a block of HTML and logic becomes too complex, it's a good idea to break it down into smaller components. Smaller components are easier to understand, test, and manage.

    Marked as helpful

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub