How can I study and learn react free from zero to completely hero
Can anybody give me a website or channel ?
L want to learn react
But I don’t have any sources
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
How can I study and learn react free from zero to completely hero
Can anybody give me a website or channel ?
L want to learn react
But I don’t have any sources
For context, I am a beginner programmer and I’m currently doing a course to change my career as a delivery driver. I am presently learning about importing and exporting modules/files in JavaScript. I have only just learnt about named exporting/importing and default exporting/importing but I am struggling to intuitively understand why my object in my examples will not export/import correctly.
As mentioned above, I am new to this so I would really appreciate it if anyone could help provide clarity to me, and show me with alternative solutions how I can implement what I am trying to accomplish along with the core fundamental reasoning and logic as to why my examples are incorrect and not working…
In the examples that will follow I am trying to Export/Import an object from a module to use it’s functionality/methods (functions)… as well as find out what is best practice for exporting/importing modules/files.
So although I assume this is an unorthodox way of understanding, tackling, and explaining this problem… I used my current understanding of the Document Object Model (DOM) and applied this same concept to what I am attempting to acheive. Therefore, I’d appreciate it if your answers could be from that same unorthodox perspective as much as you possibly can without making your solutions incorrect to make it easier for me and other beginners alike to understand as I know my logic and intuition is likely flawed. With that said, I apologise in advance if I butcher/neglect any paramount and fundamental concepts…
I’m finding it hard to understand why every imported module/file (Document) cannot just be seen as an exported Object to use and apply as one normally would use and apply a regular object such as the Document Object at the root node of the DOM tree structure?.. When using the DOM to access lets say for example an h1 element’s style, you would type document.h1.style… So just like the word “document” is clearly the selected name of the object to access all html contents (an Object named “document” by the creators of JavaScript to access the contents of the DOM/html-document-object). Why is the same concept not applied to us importing/exporting a module/file (a Document/module/file named, lets say, “yourObj” by yourself)…
If I was to encapsulate my whole module/file (document) into one object and perform a named export on this object as follows:
// In module.js
// Export example 1:
const myObj = {
exampleMethod1(num){
return num++;
},
exampleMethod2(num){
return num--;
}
}
export {myObj};
and then when importing the above module/file (document/object) in Export Example 1, why does the following not work in main.js?
// in main.js
// Import Example 1 (using Export Example 1):
import { myObj } from "./module.js";
var mainNum = 5;
myObj.exampleMethod1(mainNum);
As a beginner I am expecting the above to work and work in the same way the DOM (document object) works… Or work in the same way that any other object works, for that matter?…
And alternatively, I thought that the above Example 1 would effectively be the same as me default exporting the whole file/module as follows:
// alternatively in module.js
// Export example 2:
const myObj = {
exampleMethod1(num){
return num++;
},
exampleMethod2(num){
return num--;
}
}
export default myObj;
And similarly, when importing the above module/file (document/object) in Export Example 2 in main.js, it doesn’t work?
// alternatively in main.js
// Import Example 2 (using Export Example 2):
import myObj from "./module.js";
var mainNum = 5;
myObj.exampleMethod1(mainNum);
I was expecting to be able to use the presumably imported object (myObj) in main.js as I would within the module/file it originates from (module.js).
When looking at my course work I see that this is their solution:
// in module.js
// A Correct Export solution:
const exampleFunction1 = (num) => {
return num++;
}
const exampleFunction2 = (num) => {
return num--;
}
const myObj = {
exampleFunction1,
exampleFunction2
}
export default myObj;
// in main.js
// A Correct Import solution (using above Correct Export solution):
import myObj from './module.js'
const {exampleFunction1, exampleFunction2} = myObj;
// No idea what is happening on this above line... Seems counter-intuitive to have to
// copy/remember all functionality by name and then assign it to myObj (presumably again)?
// What happens if there are 100s or even 1000s of functions/data... would you have to
// assign each ones name in the same way?...
var mainNum = 5;
exampleFunction1(mainNum); // No use of 'myObj' prefix?...
I have a requirement to create an incident whenever an error occurs while transferring a .csv file from MID server to an SFTP server which is on a different network. I am using Export sets functionality and MID server script include to transfer the file.
I have taken this article as a reference material for the development :
I have tested the file transfer and it was successful, however I’m finding it difficult to create incidents when I tried this method below. Please let me know If there’s a way to create incidents. I also understand this transfer will be encrypted till it reaches the sftp server (while in transit). I’m attaching few blocks of code for you guys to understand:
fileTransfer: function() {
// transferring the file to the sftp server
var shortDescription = '';
var description = '';
try {
var localFileName = this.MIDSERVER_FILE_PATH + '/' + this.MIDSERVER_FILE_NAME;
var remoteFileName = this.targetPath + '/' + this.MIDSERVER_FILE_NAME;
this.log("Copying from local file of MID Server: " + localFileName);
this.sftpFile(this.targetServer, this.targetUsername, this.targetPassword, localFileName, remoteFileName);
} catch (e) {
this.log("Error in writing file to SFTP server: " + e);
shortDescription = 'Error in writing file to SFTP server';
description = 'An error occured while attempting to write the file to the SFTP server: ' + this.targetServer + ' with an error: nn' + e;
this.createIncident(shortDescription, description);
this.log("Created an Incident for the error encountered");
}
},
sftpFile: function(hostName, userName, password, localFileName, remoteFileName) {
var shortDescription = '';
var description = '';
this.log('sftpFile(): attempting to connect to ' + hostName);
var ssh = new Packages.com.sshtools.j2ssh.SshClient();
var ignoreHost = new Packages.com.sshtools.j2ssh.transport.IgnoreHostKeyVerification();
if (!this.targetPort) {
this.targetPort = 22;
}
this.log('sftpFile(): attempting to connect to ' + hostName + " on port " + this.targetPort);
try {
ssh.connect(hostName, this.targetPort, ignoreHost);
this.log("Connected to the host successfully");
} catch (e) {
this.log('Connection failed to the host ' + e);
shortDescription = 'Connection failed to the host';
description = 'An error occured while attempting to connect to the server: ' + hostName + ' with an error: nn' + e;
this.createIncident(shortDescription, description);
this.log("Created an Incident for the error encountered");
}
pwd = new Packages.com.sshtools.j2ssh.authentication.PasswordAuthenticationClient();
var authPassword = new Packages.com.glide.util.Encrypter().decrypt(password);
pwd.setUsername(userName);
pwd.setPassword(authPassword);
// Get full path of filename
this.log('sftpFile(): attempting to copy ' + localFileName + ' to ' + remoteFileName);
try {
if (ssh.authenticate(pwd) == new Packages.com.sshtools.j2ssh.authentication.AuthenticationProtocolState().COMPLETE) {
try {
sftp = ssh.openSftpClient();
this.log('Connection Established to the client');
} catch (e) {
this.log('Unable to connect to the client ' + e);
shortDescription = 'Unable to connect to the client';
description = 'An error occured while establishing a connection to the client with an error: nn' + e;
this.createIncident(shortDescription, description);
this.log("Created an Incident for the error encountered");
}
try {
sftp.put(localFileName, remoteFileName);
this.log("File successfully copied to targert pathnn");
if (this.deleteAfterUpload == "true") {
this.log("deleteAfterUpload -> " + this.deleteAfterUpload + ", deleting local file...");
new this.File(localFileName)["delete"]();
}
} catch (e) {
this.log('FILE NOT FOUND ' + remoteFileName + ' or error: ' + e);
shortDescription = 'File not found error';
description = 'An error occured while attempting to copy file from MID server: ' + localFileName + ' to target path of the SFTP server' + remoteFileName + ' with an error: nn' + e;
this.createIncident(shortDescription, description);
this.log("Created an Incident for the error encountered");
}
sftp.quit();
try {
// kill connection
ssh.disconnect();
} catch (e) {
this.log('Manual connection kill not successful with error: ' + e);
}
}
} catch (e) {
this.log('User authentication Failed ' + e);
shortDescription = 'User uthentication Failed';
description = 'An error occured while authenticating with the server: ' + hostName + ' with an error: nn' + e;
this.createIncident(shortDescription, description);
this.log("Created an Incident for the error encountered");
Thank you,
Suhail
I run a website built off angular. For months now, I had code on the site that reported each page visited. I also have a google ads account and created a conversion event to measure so I can use google automated algorithms to optimize the focus on advertising. To implement the conversion measurement event, I had to add another piece of code to my web app. When I did that, the code I had to report each page visited stopped working.
I have not been able to figure out why it stopped. I tried quite a few things including the following:
I think google recently moved their measurement properties from universal tagging to GA4 tagging, which I think is the cause of the problem. There has also been some updates to the angular version which may be a source of the problem but I don’t think that’s the case. I think it’s something on the google end, but I wanted to check here to see if anyone else had any ideas I could try.
The code looks like this:
index.html file:
<head>
<meta charset="utf-8">
<title>World Peace Catalyst Fund</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GTAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
async function gtag(){dataLayer.push(arguments);}
await gtag('js', new Date());
// gtag('config', 'Google-Ads-Tag');
await gtag('config', 'Google-Analytics-Tag' );//{ 'send_page_view': false}
</script>
</head>
appcomponent.ts
constructor(public router: Router){
this.router.events.subscribe(async event => {
if(event instanceof NavigationEnd) {
await gtag('config','Google-Anlaytics-Tag',{page_title:
event.urlAfterRedirects});//'send_page_view': true,
console.log("this is a test");
console.log("page_title:" + event.urlAfterRedirects);
}
});
The code is in the right location. I know this because the console.log fires fine. I’m pretty sure it’s the piece in the appcomponent.ts file. I think the gtag function works fine, it’s the page_title: xxx, piece that either isn’t being sent or isn’t being registered on the google end.
I’ve checked various documentation and this seems to be right, I mean, I had it working just a week ago just fine.
Also to note, this is for a non-profit I run, world peace catalyst fund. We work to catalyze world peace by facilitating cross cultural conversations. I argue that the more we communicate with each other, the more we learn about what separates us and what binds us and the closer we will be to world peace. I empower everyone to push for peace with a semiotic social media application, Icebreakers. The application reduces the communication barrier by 90%, compared to the 10% by current social media.
I thought I’d include that snippet in case anyone was interested in it… pretty neat stuff.
REST API is used. At work, I’ve recently been asked to give a request endpoint. For example, I have a request api/products/product-search. How to find out what data it returns?
Maybe it’s a stupid question, but still
For my Chrome Extension right now I use ScriptProcessorNode, which I initialize like this context.createScriptProcessor, to get audio data. But this is deprecated so I want to change it with AudioWorkletNode. My problem is that I don’t know where I can do the class AudioWorker extends AudioWorkletProcessor initialization and how I should call the audioContext.audioWorklet. and module ("./worker.js");. I’ve tried both creating the class in a separate file (audio-worker.js) or appending it to the main worker (service-worker.js) but it always throws the error that AudioWorkletProcessor is not defined. From what someone said, AudioWorklet can only work in a offscreen document?
Suppose we have three html files, one named “a” and the other two named “b” and “c“.
I want that if we move from a file named “b” to “a” file named “a“, the file “a” will show a message, but if we move from a file named “c” to “a” file named “a“, the message will not be displayed
I wanna do it in js
I tried referrer but i didn’t get result
I’m working with Mirth Connect Server 3.7.0. My code is below. I have it in postprocessor. I’m just trying to monitor the queue and send a message after it gets to x number of messages waiting. When this script executes, I am receiving the following message:
[2023-03-16 02:30:13,037] ERROR (com.mirth.connect.server.util.javascript.JavaScriptUtil:522): Error executing Postprocessor script from channel: f737be65-9f12-4e54-bab2-52c2491aeb27
com.mirth.connect.server.MirthJavascriptTransformerException: SOURCE CODE:
144: 145:
//emBody = emBody + 'Message Sent at ' + rightnow + ' n';146: 147:
var smtpConn = SMTPConnectionFactory.createSMTPConnection();
//Opens email connection using email settings in your Mirth Connect Settings.148: 149:
smtpConn.send(emTo,emCC,emFrom,emSubj,emBody);150: 151:
globalMap.put(channelId + '_lastalert',rightnow);152:
153:
LINE NUMBER:
149DETAILS:
Wrapped java.lang.NumberFormatException: null
at f737be65-9f12-4e54-bab2-52c2491aeb27_Postprocessor:149 (doScript)
at f737be65-9f12-4e54-bab2-52c2491aeb27_Postprocessor:165
at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:547)
at com.mirth.connect.server.util.javascript.JavaScriptUtil.executePostprocessorScripts(JavaScriptUtil.java:275)
at com.mirth.connect.server.transformers.JavaScriptPostprocessor$JavaScriptPostProcessorTask.doCall(JavaScriptPostprocessor.java:104)
at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:113)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)Caused by: java.lang.NumberFormatException: null
at java.base/java.lang.Integer.parseInt(Integer.java:614)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at com.mirth.connect.server.util.ServerSMTPConnection.send(ServerSMTPConnection.java:119)
at com.mirth.connect.server.util.ServerSMTPConnection.send(ServerSMTPConnection.java:156)
at com.mirth.connect.server.userutil.SMTPConnection.send(SMTPConnection.java:270)
at jdk.internal.reflect.GeneratedMethodAccessor243.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1479)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:405)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3508)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:120)
at com.mirth.connect.server.util.javascript.JavaScriptTask.executeScript(JavaScriptTask.java:150)
at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:542)
... 7 more
var rightnow = new Date(); //Current Datetime
var hLimit = 23; //Number of hours before resending
var lastsent = globalMap.get(channelId + '_lastalert');
var datediff = (rightnow - lastsent) / (1000 * 60 * 60); //calculates hours since last alert went out
if (datediff < hLimit) {
return;
} else {
//var controller = Packages.com.mirth.connect.server.controllers.ChannelUtil.getInstance();
var channelName = ChannelUtil.getChannelName(channelId);
//var stats = controller.getStatistics(channelId);
var mSent = ChannelUtil.getSentCount(channelId);
var mReceived = ChannelUtil.getReceivedCount(channelId);
var mQueued = ChannelUtil.getQueuedCount(channelId);
var mError = ChannelUtil.getErrorCount(channelId);
var qAlarm = 100; //This is the limit of queued messages prior to triggering the alert
if (mQueued >= qAlarm) {
var emTo = '[email protected]';
var emCC = '[email protected]'; //This is any cc emails you want to include
var emFrom = '[email protected]'; //This is the “From” address that will appear on your email
var emSubj = 'Queue Alert for Channel (TEST): ' + channelName; //This is the subject of the email
var emBody = 'Queued messages detected on channel (TEST) ' + channelName + '.n';
//emBody = emBody + 'Current number of queued messages is ' + mQueued.toString() + '.n';
//emBody = emBody + 'This alert will not be resent for ' + hLimit.toString() + ' hours.nPlease do not respond to this email. This address is not monitored.n';
//emBody = emBody + 'Message Sent at ' + rightnow + ' n';
var smtpConn = SMTPConnectionFactory.createSMTPConnection(); //Opens email connection using email settings in your Mirth Connect Settings.
smtpConn.send(emTo,emCC,emFrom,emSubj,emBody);
globalMap.put(channelId + '_lastalert',rightnow);
}
}
Does anyone have any ideas or could you point me in the right direction?? Thanks so much in advance for any help!!
I’m creating an app using Express and ReactJS. The user sends a POST request (which contains a JSON object {"question":"How big is the earth?"} ) to the server (using useEffect) and after handling it, a response will be generated using an API and the response will be stored in a variable, How do I send the response back to the client and display it on the front-end?
I have created a CSS grid using HTML, CSS, and JavaScript. When I initially created the grid, it displayed correctly with the borders being of a normal width. However, when I wrapped the same code into a function, the borders became thicker.
Here’s the original code that displayed the grid correctly:
const container = document.getElementById('div-container');
// create 16 row grid
for (let i = 0; i < 16; i++) {
const row = document.createElement('div');
container.appendChild(row);
// create 16 column grid
for (let j = 0; j < 16; j++) {
const column = document.createElement('div');
container.appendChild(column);
}
}
Here is what it looks like.
And here is the code wrapped into a function that displays the thicker borders:
function createGrid(rows, columns) {
//get container element where the grid will be created
const container = document.getElementById('div-container');
//create rows for the grid
for (let i = 0; i < rows; i++) {
const row = document.createElement('div');
container.appendChild(row);
//create columns for each row
for (let j = 0; j < columns; j++) {
const column = document.createElement('div');
row.appendChild(column);
}
}
}
//call the createGrid function
createGrid(16, 16);
This is what it looks like. Note the top row thickness:
grid with thicker border only on the top row
For reference here is the CSS:
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
height: 100vh;
}
h1 {
text-align: center;
margin-bottom: 50px;
}
#div-container {
justify-content: center;
display: grid;
grid-template-columns: repeat(16, 20px);
}
#div-container div {
width: 20px;
height: 20px;
border: 1px solid black;
}
footer {
text-align: center;
padding: 10px;
position: absolute;
bottom: 0;
width: 100%;
}
I’ve toggled on/off various combinations in the CSS, removed the box-sizing and tried adding margins and gaps to the container to try and see what is causing the issue but I haven’t been able to solve the problem.
It’s probably something quite obvious but I’ve been staring at this code for too long now and just can’t see it. Any help is gratefully received!
I want to figure out how to write such animations.
Can someone help write the same animation when entering the site as here: https://www.we-flow.it/.
I’m sure it’s not difficult to write it, but how.. Thank you in advance
Recently I just started learning animation, I need it urgently, help me pleeeease
I’m trying to have a prompt trigger when the user hits the log in button to sign in which they enter a security key send to their email after their credentials are confirmed via a “Login” function, but the piece that triggers my JavaScript to get the key the user typed into the prompt field will not go off on my backend code once I enter a if statement.
Button
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" Text="Login" runat="server" OnClick="Button1_Click" Width="145px" />
</ContentTemplate>
</asp:UpdatePanel>
JavaScript
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script language="JavaScript" type="text/javascript">
function GetSecurityKeyInput() {
var result = prompt('Your Security Key has been sent to your email. Please Enter it here.');
$.ajax({
type: "POST",
url: "Default.aspx/MyWebMethod",
data: JSON.stringify({ strTextBox1: result }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (myresult) {
// Can access string from MyWebMethod() in Default.aspx.cs
alert('User Input: ' + result)
},
error: function (xhr, status, error) {
var errorMessage = xhr.status + ': ' + xhr.statusText
alert('Error - ' + errorMessage)
}});
}
C#
protected void Button1_Click(object sender, EventArgs e)
{
// This will run
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "MethodUpdate", "GetSecurityKeyInput()", true);
AppClasses.user myUser = new AppClasses.user();
string str_result = myUser.login(Request.Form["uid"].ToString(), Request.Form["pwd"].ToString());
if (str_result == "success")
{
// This Never Runs, I have no clue Why
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "MethodUpdate2", "GetSecurityKeyInput()", true);
If anyone could help me out / teach me what is happening I’d very much appreciate it.
I’m writing algorithms that utilize a (FIFO) queue for efficiency. Namely, a list structure where you can append to the end of the list in O(1) time, and also remove from the front of the list in O(1) time.
Arrays can append to the end and remove from the front, but only appending to the end (with the append() method) is O(1) (amortized) time. Removing from the front (with the shift() method) is O(n) time.
Linked lists can do both appending to the end and removing from the front in O(1) time, so if there’s a good linked list implementation built into Javascript, then I could use that for efficient queues.
I’ve Googled around and haven’t been able to find either of these things – do they exist?
I have the following string: ‘[a, b]’
I want to get an array which looks like this: [“a”, “b”]
This is the code I have written:
const array = string.replace('[','').replace(']','').replaceAll(''','').split(',')
My code solves the issue I have but I want to know if there is a better way to do this compared to what I have done.
I would like to know how can I display a table with ng-repeat from angularJS like this, https://i.imgur.com/ZsHEopR.png 4 columns after a row with a colspan of 4 and so on.
My code angular return database from data html
used ng-repeat simple.
ng-repeat table dinamyc