Skip to content

This is a frontend mentor challenge just to practice and make sharp my skills. In this one, I found out how to fix React error due to google translate.

Notifications You must be signed in to change notification settings

RumerTovar/sign-up-form-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Intro component with sign up form solution

This is a solution to the Intro component with sign up form 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 site depending on their device's screen size
  • See hover states for all interactive elements on the page
  • Receive an error message when the form is submitted if:
    • Any input field is empty. The message for this error should say "[Field Name] cannot be empty"
    • The email address is not formatted correctly (i.e. a correct email address should have this structure: name@host.tld). The message for this error should say "Looks like this is not an email"

Screenshot

-Mobile

Screenshot App

-Desktop

desktopApp

Then crop/optimize/edit your image however you like, add it to your project, and update the file path in the image above.

Links

  • Solution URL: Link
  • Live Site URL: Link

My process

Built with

  • CSS custom properties
  • Flexbox
  • CSS Grid
  • Mobile-first workflow
  • React - JS library

What I learned

While building this little practice, I noticed a bug that react had when using google translate.

When google translate replaces the app's HTML tags with its translated tags, react doesn't find the references in the DOM for the tags it had created, thus causing the app to crash.

How do I solve it? Adding this little script to the top of my react app:

<script>
    if (typeof Node === 'function' && Node.prototype) {
      const originalRemoveChild = Node.prototype.removeChild;
      Node.prototype.removeChild = function (child) {
        if (child.parentNode !== this) {
          if (console) {
            console.error('Cannot remove a child from a different parent', child, this);
          }
          return child;
        }
        return originalRemoveChild.apply(this, arguments);
      }

      const originalInsertBefore = Node.prototype.insertBefore;
      Node.prototype.insertBefore = function (newNode, referenceNode) {
        if (referenceNode && referenceNode.parentNode !== this) {
          if (console) {
            console.error('Cannot insert before a reference node from a different parent', referenceNode, this);
          }
          return newNode;
        }
        return originalInsertBefore.apply(this, arguments);
      }
    }
  </script>

Here is the link where I found the solution:

Author

About

This is a frontend mentor challenge just to practice and make sharp my skills. In this one, I found out how to fix React error due to google translate.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published