-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
navigation (component) how to manage internal state? #353
Comments
I am not exactly sure what the code should be and am confused by the "accepts onClick function" where should that go? Basically want to achieve something like this. This doesn't work but just to get the idea.
|
Sorry I think to be clearer I am asking since the carousel state is being maintained internally (correct me if that is wrong) how do we modify what clicking the previous or next button does? |
2 points. // index.js
@inject(stores => ({
current: stores.box.current,
handleJumpTo: stores.box.handleJumpTo
}))
@observer
export default class PreviewImage extends React.Component {
const NavigationNextCustom = ({ ...props }) => {
return (
<div >
<button onClick={() => this.props.handleJumpTo('next', 2)}>
Jump by two
</button>
</div>
)
}
render() {
<Carousel
...props,
currentIndex={current}
>
</Carousel>
}
}
// mobx.js
class box {
@observable current = 0 // defalut value
@action handleJumpTo(direction, steps) {
if(direction==='next') {
// of course, there are some controls before we jump :)
self.current += steps
}
}
} |
Could you guys list some examples for the components. Is it possible to pull in the component as is and then edit what you would like. For example if I wanted the
NavigationNext
component and I wanted to change what the function does. Lets say something like jump by two slides, how do you alter the functionality.This what the docs say.
<NavigationNext />
Button allowing the user to navigate to the next view. Accepts an onClick function.
What does it mean accepts the onClick function and can I change the functionality.
If anyone could give a very short example that would be great. Thank you.
The text was updated successfully, but these errors were encountered: