Issue with a react lesson on beta

Hi wondering is there a error with this lesson or am I doing something wrong …
Its ment to only render on even numbers so you have to add a line of code so that it dose this
I added return nextProps.value % 2 === 0 ? true: false;
which works … but it wont pass … so not sure if error is on myside or lessons side
also the shouldComponentUpdate(nextProps, nextState) takes two paramaters I can console.log nextProps but i get nothing for nextState. so not sure what the point of nextState is here.

I agree this looks like a bug to me. The test suite says

  • The OnlyEvens component should return an h1 tag which renders the value of this. }; props.value.
  • OnlyEvens should re-render only when nextProps. }; value is even.

I’m guessing there’s a typo in the testing code.

BTW, because nextProps.value % 2 === 0 returns true or false anyway, you don’t need the ternary

return nextProps.value % 2 === 0

Nice i never thought of it that way … i probably have a few tenary in other bits of code i have done that i could replace thinking of it like this lol … ty ty

You inspired me to download the beta platform code. All the challenges are stored in a Mongo database with the tests in an array as strings. There are typos in the two tests that you had failing and fixing them fixes the problem. Oddly (imo) three of the tests are passing to begin with, so there’s really only one test for the task itself. I’ll find out tomorrow how to submit a fix for this - there’s probably a better place/way to do it than by hand-editing the database :slight_smile:

1 Like