question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clean up `name` argument usage in docs-demo component

See original GitHub issue

Couple of issues I’m having with the name argument for the docs-demo:

  1. I get Attempted to register a view with an id already in use: example-undefined a lot, because I forget to add a name. If a name is required, we should assert that it exists when the component is rendered.

  2. It seems very verbose to require a name, and then (generally) require each snippet to set its names as well. Could we use the name argument to infer the snippets for the demo? Possibly allowing us to just pass in type to each snippet?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
samselikoffcommented, May 30, 2018

How about as a first step for some sugar, docs.example can get named automatically (it will need some sort of key) and it automatically adds a demo.snippet to the list of snippets, with that name. But it’s all implicitly wired up.

That means the simplest version of docs-demo could be

{{#docs-demo as |demo|}}
  {{#demo.example}}
    <p>Hello, {{name}}!</p>
  {{/demo.example}}
{{/docs-demo}}

and that would automatically render the snippet for the example. (We could add a showSnippet=false option to demo.example.) Then, you could render the other demo.snippets as normal.

Would that be an improvement?

0reactions
savvymascommented, Jul 3, 2018

While trying to use two demos without the name argument like so:

{{#docs-demo as |demo|}}
    {{#demo.example}}
      {{bind-example}}
    {{/demo.example}}

    {{demo.snippet 'bind-snippet.hbs'}}
    {{demo.snippet 'bind-snippet.js'}}
    {{demo.snippet 'bind-snippet.css'}}
{{/docs-demo}}

{{#docs-demo as |demo|}}
    {{#demo.example}}
      {{two-lists-example}}
    {{/demo.example}}

    {{demo.snippet 'two-lists-snippet.hbs'}}
    {{demo.snippet 'two-lists-snippet.js'}}
{{/docs-demo}}

I got this error:

Uncaught TypeError: Cannot read property 'commit' of null
    at Environment.commit (runtime.js:6407)
    at Environment.commit (environment.js:266)
    at InteractiveRenderer._renderRootsTransaction (renderer.js:359)
    at InteractiveRenderer._renderRoot (renderer.js:289)
    at InteractiveRenderer._appendDefinition (renderer.js:214)
    at InteractiveRenderer.appendOutletView (renderer.js:202)
    at invoke (backburner.js:207)
    at Queue.flush (backburner.js:125)
    at DeferredActionQueues.flush (backburner.js:278)
    at Backburner.end (backburner.js:410)

This is a super confusing failure mode. I’m sharing this stack trace in case other people run into the same problem. It goes away by setting names to each example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-docs-demo-archived/.eslintrc at master - GitHub
A framework for building native apps with React. Contribute to Beomi/react-native-docs-demo-archived development by creating an account on GitHub.
Read more >
v3 Documentation - React Query Builder
The context prop is passed to each and every component, so it's accessible anywhere in the QueryBuilder component tree. operators ​. { name:...
Read more >
CLI Examples - BaseSpace Developers - Illumina
The below example commands contain example values for appsession IDs and other fields which will need to be changed for your usage. Fixed...
Read more >
Use the Name Manager in Excel - Microsoft Support
You can also sort and filter the list of names, and easily add, change, or delete names from one location. To open the...
Read more >
Changelog - React Magma
multiple: update components to use spacing from theme (11323d5); table: update tables ... multiple: clean up prop interfaces, props tables in docs (04b1ce3) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found