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.

What is the plan for dynamic elements?

See original GitHub issue

The current strategy of instrumenting JSX with a babel plugin is really neat! I’m wondering what the plan is to work around the dynamism of JSX when it comes to elements determined at runtime, such as:

Conditional Elements

{someFlag && <Display 
  {/*What is the plan for working with me and being able to toggle someFlag?*/}
/>}

Lists of Elements

data.map((item) => <div {/*What about the plan here? */} />);

Is your plan to teach the editor about these sorts of syntax expressions and render an interface for displaying these sorts of “dynamic elements”? Alternatively, Blocks could provide <If> and <Map> components to be able to statically work with these sorts things?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
johnocommented, Nov 30, 2019

Good question!

For now, the strategy I’m thinking is to slowly teach the editor about common syntax expressions. Both dynamic and lists of elements would definitely fall into common!

With dynamic elements based on flags/ternaries I’m hoping to expose the element in the tree (or two elements for a ternary) with a toggle. Will mostly be a matter of locating the syntax at the root level and adding support for it in the blocks selection/editing of the canvas.

Lists are more interesting because we’ll need to search for this syntax and expose the list in some unified interface for editing the rendered component being mapped over. Interestingly we’ll get manipulating the mapped over element for free as a result of the UUID being used to apply props.

1reaction
ackvfcommented, Dec 30, 2019

Why bother with AST and not use control components?

Instead of this

{someFlag && <Display />}

{data.map((item) => <div />)}

{someOtherFlag
  ? <Yes />
  : <No />}

write this

<Branch condition={someFlag} truthy={<Display />} />
<List items={data} />
<Branch condition={someOtherFlag} truthy={<Yes />} falsy={<No />} />

The advantage is that these proprietary components can attach special interaction and editing possibilities.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Elements, Static Elements, Event Handlers and Their ...
When the page loads, two dynamic elements are created. When the first is clicked, it should display the second dynamic element. When the...
Read more >
Use dynamic elements in interactive overlays - Vimeo
Dynamic Elements is a feature available in the interactive overlay panel to pull content from any open API and integrate it into the...
Read more >
Dynamic Web Elements in Web Automation | by Adil Qayyum
The dynamic element is that Web Element whose IDs, and any other attributes like Class Name, Value etc. are not fixed. It changes...
Read more >
What are Dynamic Elements? - KIRUPA
The answer lies in a mysterious creature known as the dynamic element and the role it plays in our everyday lives. In the...
Read more >
The Elements of a Dynamic Growth Plan
The Elements of a Dynamic Growth Plan. Time. Frames. Planning Elements. Clarifying Questions. Lo n g. Te rm. 5. – 2. 5. Y...
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