React wrapper for WanaKana.js
https://wanakanareact.netlify.com
- Add ability to use a custom component
// default - romaji to kana
<WanakanaInput value="konnnichiwa" />
// kana to romaji
<WanakanaInput to="romaji" value="こんにちわ" />
// romaji to hiragana
<WanakanaInput to="hiragana" value="konnnichiwa" />
// romaji to katakana
<WanakanaInput to="katakana" value="TABERU" />
Name | Value |
---|---|
to | kana (default), romaji , hiragana , katakana |
component | any valid dom element (input , textarea , etc) |
import WanakanaInput from 'react-wanakana';
const WanakanaInput = () => {
const [greeting, setGreeting] = useState('こんにちわ');
const handleChange = e => {
setGreeting(e.target.value);
};
return (
<form
onSubmit={(e, values) => {
e.preventDefault();
alert(greeting);
}}
>
<WanakanaInput name="greeting" value={greeting} onChange={handleChange} />
<button type="submit">Submit</button>
</form>
);
};
npm run storybook