🏠 back to Observable

Question about syntax differents between Observable and React

I am trying to embed the old inputs notebook into my react app. React throws the error saying “expected an assignment or function call and instead saw an expression no-unused-expressions”. React says in the “Button” part of the notebook, the syntax
{ b return (!this); }
{ b1; return new Date(Date.now()).toUTCString() }
are not allowed. What should be the correct syntax for this?

I solved the problem by commented out those two lines, but I am still curious about the correct syntax.

It looks like you forgot to add a URL to your link. I assume you’re referring to Inputs / Jeremy Ashkenas / Observable?

Note that

{ b return (!this); }

is invalid syntax. In the original notebook, both statements are separated by a newline:

  return !this;

In your example, b1; is likely considered an unused expression. Perhaps try this instead:

{ return b1, new Date(Date.now()).toUTCString() }

However, I suspect that you’re dealing with two separate errors:

“expected an assignment or function call and instead saw an expression"

is a compile error that needs to be fixed.

“no-unused-expressions” .

seems to be an es-lint error that you can likely disable.