That means, you need to either alias it as uCyr in the calling code, or not use {} during import.
// from import{Ucyr}from"./Ucyr";// to eitherimportUcyrfrom"./Ucyr";// or import{defaultasUcyr}from"./Ucyr";
2nd issue
To bind an event handler, you shouldn't pass a string to onClick but actual function expression.
// instead of <buttononClick="Ucyr()">УЋИРИЛИЦУ</button>
// You should do<buttononClick={()=>Ucyr()}>УЋИРИЛИЦУ</button>
// or using a short-hand syntax<buttononClick={Ucyr}>УЋИРИЛИЦУ</button>
Recommendation
Instead of getting the textarea using document.getElementById("textarea"), you should store the textarea value as a React state. Or you can use ref (but discouraged).
It seems like you are used to the jQuery's unobstrusive coding style, but React requires a different mindset.
All changes should be state driven.
If you are unfamiliar with React states, I'd recommend React documentation.
My reply is based off on your Sandbox: codesandbox.io/s/strange-dust-98uwd
You can follow along w/ my fork: codesandbox.io/s/objective-mcnulty...
Here are a few things worth mentioning.
First issue
You are exporting
uCyr
as a default module.That means, you need to either alias it as
uCyr
in the calling code, or not use{}
during import.2nd issue
To bind an event handler, you shouldn't pass a string to
onClick
but actual function expression.Recommendation
Instead of getting the textarea using
document.getElementById("textarea")
, you should store thetextarea
value as a React state. Or you can useref
(but discouraged).It seems like you are used to the jQuery's unobstrusive coding style, but React requires a different mindset.
All changes should be state driven.
If you are unfamiliar with React states, I'd recommend React documentation.
reactjs.org/docs/state-and-lifecyc... or other materials of your choice because it's a very basic React knowledge required.
Thank you very much. You've helped me a lot
You're welcome & have fun with React~