GithubHelp home page GithubHelp logo

react-events-in-detail-lab's Introduction

React Events in Detail

Overview

In this lab, we will practice using event data and persisting events. We will be working with event data you may not be familiar with: event.clientX and event.clientY. These provide the current x/y position of a mouse. Links are provided in the resources section to learn more.

Two Buttons To Rule Them All

Using buttons

In this lab, you'll be working on two components โ€” two buttons, to be more precise. These aren't just regular buttons, however! They both serve a very specific purpose.

Instructions

In src/index.js, code for a basic React app is already provided. Two of the components referenced, CoordinatesButton and DelayedButton, are being passed props. However, these components are not written yet, causing the application (and learn) to crash. Using the provided component files, follow the instructions below to create these components. Run learn to track your progress through the lab.

CoordinatesButton

  1. In the components/CoordinatesButton.js file, create a CoordinatesButton React component.

  2. This component takes in one prop: onReceiveCoordinates. This prop is a function passed down from index.js. This function is currently just logging whatever is passed into it.

  3. Within CoordinatesButton, render a button. On click of the button, create an array with two elements: the X and Y coordinates of the mouse. Find these using the event data.

  4. Pass this event data in as the argument for the onReceiveCoordinates prop.

  5. If successful, the current x,y position of your mouse should be logged.

DelayedButton

  1. In the components/DelayedButton.js file, create a DelayedButton React component

  2. This component takes two props: onDelayedClick (a function), and delay (a number).

  3. Create a button that, when clicked, will pass the click event to the onDelayedClick prop within a setTimeout(). The setTimeout() should be set to this.props.delay.

  4. If successful, the event will be logged to the console once the timeout has finished.

  5. Hint: If you having trouble with this feature, remember event pooling in React. By the time the setTimeout fires, the event object will have already been returned to the pool. So how can we fix that?

Resources

react-events-in-detail-lab's People

Contributors

achasveachas avatar annjohn avatar enoch2k2 avatar gj avatar ihollander avatar kjleitz avatar lukeghenco avatar maxwellbenton avatar nikymorg avatar pletcher avatar thomastuts avatar thuyanduong-flatiron avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-events-in-detail-lab's Issues

What is the purpose of this lab?

Honestly, I don't feel I'm learning how to use React! And it's very frustrating.

I completed the lab, but have no understanding of what the component is supposed to do! Especially when I can't test the app in the browser.

I feel I'm executing isolated tasked without properly understanding how they work in the big picture.

I've decided to take a React course on Udemy and then come back to complete these lessons and labs. Hopefully then I'll learn how to use React properly...

I apologize for all the complains but after knowing and experiencing how you guys can deliver amazing curriculum (as was the case with Ruby, Rails, even the JavaScript track) this track is really disappointing...

Poor instructions

The delayedButton instruction are not clear, and with limited test output, are very difficult to translate into the desired outcome. There is also no solution present.

Passing Written Tests, Browser Errors

Hello! I wanted to bring awareness to this lab. I was able to pass the tests that were written for the lab but I had errors in the browser when I actually used the the buttons(to click them) and see their action.

I also noticed that the two functions onReceiveCoordinates and onDelayedClick are part of the tests but nowhere in my code did I define these functions. I assume this may be why I am receiving browser errors overall.

Since passing the tests I decided to move on because I couldn't linger any longer on a lab. I did want to make sure this was looked at though. I provided the browser errors I received for both functions and my passing tests in the console.

Happy coding
Malind

ondelayedclick
onreceivecoordinates
consoletests

wording confusing

the wording for coordinates button #2 is very confusing. The words "takes in" makes it sound like it should be entered as an argument to a method.

readme is unclear on functions defined in test suite

This is very unclear in the readme (as are many other things), but onReceiveCoordinates and onDelayedClick are functions that are defined in the test suite and passed in as props when the tests are run. Students do not need to define these as props in their component files, and this should be made clear in the readme, especially given how uninformative the error messages in the tests are.

just a suggestion for this lab

since this is brand new stuff i'm (and most people) are learning at this point, it would be helpful to see the code that we are writing render in the browser.

Starting with this react lab, It appears the components you create don't render in the browser and i'm not sure if thats a sign of things to come in future labs. The visual rendition and ability to console log stuff etc is important when testing to see if things work. Not having that ability is really not helpful - its kinda like driving a car but not being able to see through the windshield.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.