1

I am trying to implement JavaScript library to my mobile app that I am creating with React Native. This app should have flashcards with Chinese characters and its stroke order, but I dont know how to add this library to the react nor how to use it afterwards.

Library: https://github.com/chanind/hanzi-writer

I already try it in the browser, everything works as described in docs, but I cant find a way to implement it in my mobile app.

In html I can do something like this to have a flashcard with one character

<html>
    <head>
        <title></title>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/hanzi-writer.min.js"> </script>
    </head>
    <body>
        <div id="character-target-div"></div>
        <script type="application/javascript">
                var writer = HanziWriter.create('character-target-div', '我', {
                        width: 100,
                        height: 100,
                        padding: 5
                });
                writer.quiz();
        </script>
    </body>
</html>

2 Answers 2

1

After running npm install ‘hanging-writer’ in your root folder, on top of your module add: import {HanziWriter} from ‘hanzi-writer'

Sign up to request clarification or add additional context in comments.

Comments

1

First you have to run npm install hanzi-writer-data Then run this npm install hanzi-writer It works fine for me

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.