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.

remove the "stack", use HOCs instead

See original GitHub issue

@rockymeza had the very interesting idea, in our Slack, of writing plugins as React components. Potentially even using HOCs to re-implement all of the logic that is currently handled by the custom plugin system.

I think this is really interesting, and has the potential to simplify some things in core, and kinda seems obvious now that I think about it, which good ideas often do.

Haven’t fully fleshed this out yet, but…

  • We could get rid of the Stack concept, since HOCs would imply the ordering, and they can easily override or passthrough to the Editor as they please. This would also eliminate the potential hidden performance impact to re-creating the stack on every render, since it would be obvious that re-creating the Component on every render would have negative performance impacts.
  • We could remove the render and renderPortal properties of plugins, since they would be supported automatically with HOCs.
  • We might be able to remove storing state in this.state.state, and instead just use this.props.state, simplifying some logic.

If you have thoughts, please add! Especially if there are holes that aren’t possible with HOCs that we’d need to figure out.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
rockymezacommented, Aug 21, 2017

I have managed to get some time from work to work on this the next two weeks. I’m going to put a base together and port some of our internal plugins to it. I’m going to try to come with something as ergonomic as possible first and then think about how to port the legacy plugins to it. I will post back here when I have something to look at.

1reaction
ms88privatcommented, Aug 28, 2017

@danburzo About performance of multiple HOC’s. There are attempts to combine multiple HOC’s into one HOC automatically by various “recompose” libraries

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning when using react hooks in HoC - Stack Overflow
When I write a HoC, I often have to disable the rules-of-hooks eslint rule because the rule is too stringent wrt what it...
Read more >
Higher-Order Components - React
A higher-order component (HOC) is an advanced technique in React for reusing component logic. HOCs are not part of the React API, per...
Read more >
Refactoring Higher-Order Components (HOC) to React Hooks
In this post I'll be converting one of these HOCs to a custom Hook, to demonstrate the power of this "new" pattern. Sidenote:...
Read more >
Why hooks are the best thing to happen to React
With hooks, it's now simpler to learn React; because of this, its use in the tech world today has grown: A chart showing...
Read more >
Stack Marks - Tableau Help
When marks are stacked, they are drawn cumulatively along an axis. ... Instead, they are drawn independently from the horizontal axis. Back to...
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