We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// 代码开始, 别再放歪了行吗 import { FC, useRef, useEffect, useCallback, forwardRef, useImperativeHandle } from 'react' import { LuckyWheel as Wheel } from 'lucky-canvas' import styled from './luckyWheel.module.less' export type LuckyWheelRef = { play: () => void stop: (index: number) => void } const LuckyWheel: FC<any> = forwardRef((props, ref) => { const luckyWheelEl = useRef<HTMLDivElement>(null) const luckyWheelRef = useRef<any>() const init = useCallback(() => { if (!luckyWheelEl.current) return luckyWheelRef.current = new Wheel( { flag: 'WEB', divElement: luckyWheelEl.current, width: props.width, height: props.width }, { ...props, start: (...rest) => { props.onStart && props.onStart(...rest) }, end: (...rest) => { props.onEnd && props.onEnd(...rest) } } ) console.log(luckyWheelRef.current) }, [props]) const play = () => { luckyWheelRef.current && luckyWheelRef.current.play() } const stop = (index: number) => { luckyWheelRef.current && luckyWheelRef.current.stop(index) } useEffect(() => { try { init() } catch (e) { // } }, [init]) useImperativeHandle( ref, () => ({ play, stop, luckyWheelRef }), [] ) return <div className={styled.wheel} ref={luckyWheelEl}></div> }) LuckyWheel.displayName = 'LuckyWheelRef' export default LuckyWheel // 代码结束
感谢!!!
The text was updated successfully, but these errors were encountered:
.....我不会react, 所以我也不知道为啥
Sorry, something went wrong.
No branches or pull requests
Next.js React Typescript
lucky-canvas
@1.7.13
浏览器
当我参照楼主写的React class组件,封装一个函数组件时,转盘无法转动。
感谢!!!
The text was updated successfully, but these errors were encountered: