JaredReisinger / react-crossword

A flexible, responsive, and easy-to-use crossword component for React apps.
https://react-crossword.jaredreisinger.com
MIT License
168 stars 80 forks source link

Imperative methods & Player progress events #562

Closed mlava closed 4 months ago

mlava commented 5 months ago

Hi there, Sorry to be a noob, but would someone please mind sharing some code showing how to access and use these methods? I searched through the examples, but couldn't see anything that made sense. Thanks in advance!

CodeDecree commented 4 months ago

Do write this inside any functional component.

export default mycomp() {

const [score, setScore] = useState(0);
 return (
      <CrosswordProvider data={crossword} onAnswerCorrect={() => setScore(score + 1)}>
                <DirectionClues direction="across"/>
                <DirectionClues direction="down" />
                        <CrosswordGrid />
            </CrosswordProvider>
   )
}

Do let me know if you need any further assistance

mlava commented 4 months ago

Thanks very much @CodeDecree I will experiment and see how it goes. Cheers!