Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better ergonomics around numbers/booleans #761

Closed
rorticus opened this issue Apr 29, 2020 · 0 comments · Fixed by #781
Closed

Better ergonomics around numbers/booleans #761

rorticus opened this issue Apr 29, 2020 · 0 comments · Fixed by #781
Assignees

Comments

@rorticus
Copy link
Contributor

rorticus commented Apr 29, 2020

Enhancement

It would be nice to be able to support numbers / booleans in vdom without having to cast them to strings.

In this example, there is no output as clickCount is a number.

https://codesandbox.io/s/tender-monad-c3y9p?file=/src/main.tsx

import { renderer, create, tsx } from "@dojo/framework/core/vdom";
import icache from "@dojo/framework/core/middleware/icache";
import "@dojo/themes/dojo/index.css";

const factory = create({ icache });

const App = factory(function App({ middleware: { icache } }) {
  const clickCount = icache.getOrSet("clickCount", 0);

  return (
    <div>
      <h2>Click the button to increment the click counter</h2>
      <button
        onclick={() => icache.set("clickCount", icache.get("clickCount") + 1)}
      >
        Click me!
      </button>
      <br />
      <br />
      <div>Clicked: {clickCount}</div>
    </div>
  );
});

const r = renderer(() => <App />);
r.mount();

If it's too much effort to support numbers/booleans, it would be at least nice to throw an error in vdom explaining that it encountered a number/boolean.

@maier49 maier49 self-assigned this May 21, 2020
@maier49 maier49 mentioned this issue May 22, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants