-
Notifications
You must be signed in to change notification settings - Fork 131
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
can you provide a syntactic sugar? #122
Comments
For a dom node like Passing props cross components by syntactic sugar will make components very hard to manage and confusing. |
but, in this particular case, that we just want bind the event to the root node function Father() {
{state ? <Child onClick={toggle} /> : null}
}
function Child() {
return (
<div class='root'> // so here , at root node, we can omit 'onClick={func}'
<button>child</button>
</div>
)
} |
The Child must determine which node accepts click events. Suppose it renders a wrapper node that holds a primary button and other nodes. The outer node should not intercept the prop. const Child = ({ onClick }) => (
<div style={...}>
<button onClick={onClick} />
<button onClick={...} />
<button onClick={...} />
</div>
); The Child should also be able to reject event handlers based on internal logic. const Child = ({ onClick }) => {
const [isBusy, setBusy] = useState(...);
return <div onClick={isBusy ? undefined : onClick} />;
} |
in this case, we just want bind the click event to the child root
so, should there has a syntactic sugar like this?
thanks
The text was updated successfully, but these errors were encountered: