Coder Social home page Coder Social logo

react-forms's Issues

formData as global variable

formData = { firstName: this.state.firstName, lastName: this.state.lastName }

should be either const or let?

Typo on ReadMe

handleFirstNameChange = event => {
this.setStaet({
firstName: event.target.value
})
}

handleLastNameChange = event => {
this.setStaet({
lastName: event.target.value
})
}

Under 'Why Use Controlled Forms When We Do Not Have To'

Code doesn't work. I added an import of my parent component to my index.js. I also tried debugging the code myself but in the end the code will not work as it is. I did not spend to much time debugging but didnt get it to work. The first error it throws is

TypeError: Cannot read property 'firstName' of undefined

I don't know what this means

To control the value of these inputs, we use a prop specific to that type of input:
For and <textarea>, we use value --- WHERE?
For and , we use checked -- IN WHAT CONTEXT?
For , we use selected -- WHO IS WE?

This was clearly written by someone who understands the materials but doesn't understand our current level of understanding. Please flesh this out.

loginForm-test.js -> spy is called twice not once.

In loginForm-test.js there is an issue in the following test:

    it('should call the `onSubmit` callback prop when the form is being submitted', () => {
      const wrapper = shallow(<LoginForm onSubmit={spy} />);
      wrapper.find('#test-username').simulate('change', { target: { value: 'johndoe' } });
      wrapper.find('#test-password').simulate('change', { target: { value: 'supersecret' } });
      wrapper.find('form').simulate('submit', { preventDefault: spy });
      expect(spy.calledOnce, 'The `onSubmit` prop is not being called exactly once').to.be.true;
    });

As per the spec of the test before it, event.preventDefault should be called whenever the form is submitted. However, in this case spy is passed in as both the event.preventDefault override and the onSubmit property. Causing it to be called twice and have the test fail

A workaround a student can use is to not prevent default on valid input. However that is not the intended spec as you can see from the implementation on the solution branch or the readme.md. replacing

expect(spy.calledOnce, 'The `onSubmit` prop is not being called exactly once').to.be.true;

with

expect(spy.calledTwice, 'The `onSubmit` prop is not being called exactly once').to.be.true;

solves this issue.

Warning: Each child in a list should have a unique "key" prop.

When submitting the first form, controlled form example, I get the above warning in the browser.
A key should be provided for list items. From React spec: "Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity"

Solution:
listOfSubmissions = () => {
return this.state.submittedData.map((data, idx)=>{
return

{data.firstName}{data.lastName}

})
}

No "start" script in package.json

The instructions say that we can code along with the following instructions:

Make sure to run npm install && npm start to see the code in the browser.

However we cannot use "npm start" because in the package.json files there is no script for "start". This actually has been happening for the last few labs and code-alongs beginning with the Props section. All the package.json files do not have a script for "start".

Readme

This is a reading. It should not look for tests to be passed.

typo

"Whenever our state\ changes, the component re-renders, rendering the input with the new updated value."

extra slash after 'state'

It's not Its

Need an apostrophe on the first word in this sentence:
"Its already being displayed after all."

Thank you.

example code does not work as described by the READme

Hi,

I was able to learn a lot from this lesson, but there were a few confusing things about the directions and code. Here are a couple suggestions to clarify it.

The directions for using the example code seem to imply that when you enter a new value into the input field, the input field will keep that new value when viewed in the browser. However, it reverts back to the the initial state that was set. To fix this, I used the example code from the 'React Forms' resource at the bottom of the lab and that seemed to get it working as described by the READme. Other people may have had better luck, but I think either the directions could be updated with screenshots to show what should happen in the browser (maybe I was misunderstanding what should happen) or the code may need to be updated to display correctly. Maybe a complete constructor function needs to be added?

The Bonus section refers to code in the ControlledInput component, but is from early in the lesson (before the lab clearly stated which code to put in the starter code files). It would be easier to read if that code was added to code to put in the starter code files so we could see how it all fits together more clearly.

Thank you!

typo

Controlled forms can very useful for specific purposes - since we can set...

Video link at the bottom doesn't work

One of the reference files at the bottom of the page doesn't work (Video: Controlled vs Uncontrolled Components in React). The link itself works but there is an error playing the video.

image

Typo in Bonus Section

In Bonus section,

If we give our inputs name attributes, we can accss them as event.target.name:

has "access" spelled incorrectly.

setState typos

In multiple code snippets in the readme, setState is typo'd as setStaet. Should be easy to find with a find and replace. This is only in the example snippets, and never in the ones that are meant to be copy pasted into the code along.

typo

"Whenever our state\ changes, the component re-renders,..."

what does backslack do?

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.