Conditional rendering
See original GitHub issueHi
I reviewed branch next
and decided that I will add features mentioned in PRs #41 and #42 there as it makes more sense. You addressed already disabling on function and passing data to the onClick.
Therefore I have few items left to add:
-
visible
prop inItem
which is eitherboolean
orfunction
where, function has access to passed data (use case: some items exists only for specific data) -
toggleContextMenu
as a function, when you need create context without new DOM node (use case: I want div which is draggable and is also context menu provider)
Please proceed with next
branch.
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Conditional Rendering - React
In React, you can create distinct components that encapsulate behavior you need. Then, you can render only some of them, depending on the...
Read more >React Conditional Rendering - W3Schools
Another way to conditionally render a React component is by using the && operator. Example: We can embed JavaScript expressions in JSX by...
Read more >React conditional rendering: 9 methods with examples
In React, conditional rendering refers to the process of delivering elements and components based on certain conditions.
Read more >7 Ways to Implement Conditional Rendering in React ...
Conditional rendering is a term to describe the ability to render different user interface (UI) markup if a condition is true or false....
Read more >Six methods to achieve conditional rendering in React - Flexiple
What is Conditional Rendering? ... While developing an application in React or any other JS library/ framework, it is a common use case...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case anyone’s interested, I was able to implement conditional rendering with the current API, it came out pretty clean (IMHO). Here’s a sketch:
I’m using react-redux, so I wrap that in a
connect(mapStateToProps)
for the menu to depend on the app state, and for the click handlers to be able todispatch()
Invoke the context menu with a ref:
This has the nice side-effect (IMHO) that the caller is completely insulated from the react-contextify API.
Hello @ronen,
Your implementation is 👌. I’ll close the issue.