learn-co-curriculum / react-updating-state-lab Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
when use "npm server" server does not start, error messages result. When follow instructions to resolve, does not resolve. Therefore, just used "tests" with no browser feed-back for this lab.
https://learning.flatironschool.com/courses/1883/assignments/125708?module_item_id=259621
Clicking 'Next' skips over the 'React Controlled Components' code-a-long lab.
Not sure if it is buggy on my end but I refreshed the page and tried it a couple times and it keeps skipping the lab. I didn't realize I skipped it till I completed the lab before the reading and code-a-long.
Adjust link so that it connects to the proper lab.
This component has several state properties. The initial state shape looks like this: js { errors: [], user: null, settings: { bitrate: 8, video: { resolution: '1080p' } } }
The curriculum states the spread operator is recommended so I think the solution should prioritize that solution, rather than the object.assign().
Also, the solution for updating the digital clicker is MUCH MORE COMPLEX than necessary, and includes life-cycle components, even tho that is 2 sections ahead.
solution should be:
handleClick = () => {
this.setState({
timesClicked: ++ this.state.timesClicked
})
}
The instructions were clear and felt more prepared to complete the lab on my own.
When using npm run bundle
or yarn run bundle
to execute Browserify script, the following error comes up.
Error: Cannot find module 'react-test-renderer/shallow' from '/Users/stevefrost/Development/react-updating-state-lab-v-000/node_modules/enzyme/build'
This is fixed by adding react-test-renderer
as a devDependencies in package.json
. I've created a pull request that can be found here if this fixes the issue for you as well.
The idea of grabbing information from a previous state hasn't yet been covered in labs. It should be mentioned, at the very least, and preferably covered explicitly in a ReadMe or lab.
If a student is receiving this error, check that inside their JSX, className
is defined correctly
The README doesn't indicate this, but in order for the YouTubeDebugger tests to work, you need to wrap the <button>
s in a <div>
or some other HTML element.
Here's what I did initially (without giving away the whole solution):
render() {
return ([
<button></button>,
<button></button>
])
}
It worked in the Chrome browser, but the test output looked like this:
1) <YouTubeDebugger /> should have the correct initial state:
Error: Method “state” is meant to be run on 1 node. 2 found instead.
at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1652:13)
at ShallowWrapper.state (node_modules/enzyme/src/ShallowWrapper.js:1194:25)
at Context.<anonymous> (test/index-test.js:55:20)
at processImmediate (internal/timers.js:456:21)
2) <YouTubeDebugger /> should update the bitrate when the `.bitrate` button is clicked:
Error: Method “setState” is meant to be run on 1 node. 2 found instead.
at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1652:13)
at ShallowWrapper.setState (node_modules/enzyme/src/ShallowWrapper.js:742:10)
at YouTubeDebugger.ShallowWrapper.instance.setState (node_modules/enzyme/src/ShallowWrapper.js:422:66)
at YouTubeDebugger._this.changeBitrate (src/components/YouTubeDebugger.js:21:10)
at node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:716:13
at withSetStateAllowed (node_modules/enzyme-adapter-utils/src/Utils.js:99:18)
at Object.simulateEvent (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:712:11)
at ShallowWrapper.<anonymous> (node_modules/enzyme/src/ShallowWrapper.js:1134:7)
at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1654:21)
at ShallowWrapper.simulate (node_modules/enzyme/src/ShallowWrapper.js:1133:17)
at Context.<anonymous> (test/index-test.js:63:30)
at processImmediate (internal/timers.js:456:21)
3) <YouTubeDebugger /> should update the video resolution when the `.resolution` button is clicked:
Error: Method “setState” is meant to be run on 1 node. 2 found instead.
at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1652:13)
at ShallowWrapper.setState (node_modules/enzyme/src/ShallowWrapper.js:742:10)
at YouTubeDebugger.ShallowWrapper.instance.setState (node_modules/enzyme/src/ShallowWrapper.js:422:66)
at YouTubeDebugger._this.changeVideoResolution (src/components/YouTubeDebugger.js:32:10)
at node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:716:13
at withSetStateAllowed (node_modules/enzyme-adapter-utils/src/Utils.js:99:18)
at Object.simulateEvent (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:712:11)
at ShallowWrapper.<anonymous> (node_modules/enzyme/src/ShallowWrapper.js:1134:7)
at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1654:21)
at ShallowWrapper.simulate (node_modules/enzyme/src/ShallowWrapper.js:1133:17)
at Context.<anonymous> (test/index-test.js:73:33)
at processImmediate (internal/timers.js:456:21)
In order to get the tests passing, I had to wrap the <button>
elements in a <div>
:
render() {
return (
<div>
<button></button>
<button></button>
</div>
)
}
As I said above, though, the README doesn't tell us to do this at all.
Thanks, as always, for looking into this!
Sdcrouse
In the solution code, it's writtentimesClicked: ++this.state.timesClicked
, which basically defeats the purpose of using setState()
On my end, bitrate changes to 12, yet the tests argues that it is 8.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.