Skip to content
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

react中同一个页面中,多个组件内如何区分使用不同的scope区域呢,比如向下键如何复用 #14

Open
changbinchen opened this issue Jun 3, 2019 · 2 comments

Comments

@changbinchen
Copy link

No description provided.

@jaywcjlove
Copy link
Owner

@changbinchen 这个是 hotkeys-js 基础封包,你可以基于它封包,放出 API,将 scope 放到全局 state 上 在根组件上使用 react-hotkeys,通过全局 state 来控制 scope

@changbinchen
Copy link
Author

changbinchen commented Jun 3, 2019

没理解,能简单写个例子吗,比如以下两个div,复用键盘,思路是什么呢

<div className="itemDiv" >
    <Hotkeys
        keyName="up,down,a,space"
        onKeyDown={this.onKeyDown.bind(this)}
    >
        <div className='demo1'></div>
    </Hotkeys>
    <Hotkeys
        keyName="up,down,a,space"
        onKeyDown={this.onKeyDown.bind(this)}
    >
        <div className='demo2'></div>
    </Hotkeys>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants