Comments (11)
Thanks for your question. We just found a bug in our code and get fixed.
For your question, the headerContent
you need to pass in is something like this.
class Header extends React.Component {
render() {
return <input onClick={this.props.startSearching} value={this.props.searchInput}
onChange={this.props.setSearchInput}/>;
}
}
We provided the default filter method for searching.
from react-infinity-menu.
Ahhh I see. Okay I will give that a shot. I guess in the same vein, how does one pass a customComponent? For example, in the json from my server, I set my customComponent field for a nod to be "NodeWrapper" (as a string), but that doesn't seem to be reflected in the DOM. Thanks again!
from react-infinity-menu.
I am not sure I understand your question. But if just for passing in an customComponent
. you can do something like this
<InfinityMenu tree={this.state.tree} headerContent={Header}/>
from react-infinity-menu.
I'm sorry, I worded that poorly. I'm talking about this case:
[
{
name: "menu1", /*require*/
id: 1, /*require*/
isOpen: true, /*require*/
customComponent: YOUR_OWN_COMPONENT_FOR_MENU,
children: [
{
name: "submenu1",
id: 1,
isOpen: true,
customComponent: YOUR_OWN_COMPONENT_FOR_SUB_MENU,
children: [
{
name: "item1-1",
id: 1
},
{
name: "item1-2",
id: 2
}
]
},
{
name: "submenu2",
id: 2,
isOpen: true,
customComponent: YOUR_OWN_COMPONENT_FOR_SUB_MENU,
children: [
{
name: "item2-1",
id: 1
}
]
}
]
},
{
name: "menu2", /*require*/
id: 2, /*require*/
isOpen: true, /*require*/
customComponent: YOUR_OWN_COMPONENT_FOR_MENU,
children: [
{
name: "item3-1",
id: 1
}
]
}
];
This is in the README and I have designed my payload from the server to look like that, but i'm just not sure how to make the customComponent
portion work. I hope that i've clarified the question a little more. Thanks.
from react-infinity-menu.
I see. Ah, no worries.
So for the customComponent
is an react component that let you to customize the menu. Inside this customComponent
, you can access different properties of current node. Here is an simple example that you can pass in as an customComponent
class Node extends React.Component {
render() {
return (
<div key={this.props.key} onClick={this.props.onClick}>
<label>{this.props.name}</label>
</div>
);
}
}
from react-infinity-menu.
Hmmm but how do you define that component in the data structure?
from react-infinity-menu.
oh you will usually define this outside of the tree data structure and pass in as an variable.
class Node extends React.Component {
render() {
.......
}
}
tree = [
{
name: "menu1",
id: 1,
isOpen: true,
customComponent: Node
}
];
from react-infinity-menu.
Alright that makes sense, I think I can work with that. Do you also have any recommendations on improving performance of the search mechanism for large data sets? Thanks.
from react-infinity-menu.
Glad to see you found this lib useful @jamesoh :)
from react-infinity-menu.
@jamesoh For large data sets, we may need some pre handling the data before we create the menu. and when we do the searching we can use the pre-set data. Currently, we are searching the whole tree by using recursive method which is pretty slow for large data.
We will also refactor the search input a little bit since right now it's not very intuitive to use
from react-infinity-menu.
@johnelliott yea, i'm really enjoying the ability to customize the menu
@tiansijie I see, i'll try building something on my end to handle that for now. I'll contribute if i can get my solution generic enough for this library
Thanks for all the help guys!
from react-infinity-menu.
Related Issues (19)
- Remove immutable js
- inline default style
- Too much recursion HOT 6
- Update component while searching HOT 8
- too many leaves HOT 2
- IE11 compatibility HOT 1
- Is there a way to add animation? HOT 2
- in "onLeafMouseClick", an "data-reactid" of the leaf is passed in instead of the "leaf" object when using customComponent for leaf HOT 5
- remove full lodash dependency
- Uncaught TypeError: _react2.default.unmountComponentAtNode is not a function HOT 4
- No newest version (V 3.2.0) found in NPM HOT 1
- Search functionality not working as expected with numeric values HOT 4
- Custom component as leaf in main menu level HOT 1
- menu element onClick- bold HOT 1
- invariant violation HOT 1
- css file not import HOT 2
- Can we default the placeholder for search instead of being empty?
- Open Source this HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-infinity-menu.