fbpx
Home Blog Page 1042

10 React Interview Questions to Practice

0
10 React Interview Questions to Practice
10 React interview questions to practice

React is an open-source JavaScript framework developed by Facebook. It’s currently the most popular front-end framework in use today. Its success even convinced Facebook to develop React Native, another framework that uses React for cross-platform mobile development.

When you’re interviewing for a job that requires using React daily, employers want to know that you have the skills needed to get the job done. That means your interview will likely include React interview questions, and while we can’t guess precisely what they’ll ask, we’ve collected some of the most popular ones here, along with possible answers.

1. What is React, and how is it different from other JavaScript frameworks?

With this question, the interviewer wants to find out if you know about the JavaScript ecosystem in general and what makes React unique. One thing you could bring up is that while some developers call React a framework, many consider it a library and not a full framework.

This is because React’s purpose is to build UI components for your web app. That’s all it really does. It’s the V (or View) part of an MVC (Model, View, Controller) architecture, and to build a complete application with React, you need other libraries like Redux.

Most JavaScript frameworks, like AngularJS, have tools for creating controllers, directives, services, and other functionalities. With these other frameworks, you have to use the tools you’re given for the most part. With React, you can build an application with the libraries of your choice.

2. What is JSX?

JSX is a language that React uses to embed an HTML template in code. It isn’t understood by browsers and must be transpiled with tools like webpack and Babel before it can be run.

Still, JSX helps streamline React development once you know its syntax. You don’t actually have to use JSX to create React components and can use React.createElement() instead, but Facebook recommends using JSX. Most React developers prefer its declarative syntax, and it also reduces code complexity.

Here’s an example of JSX:

return( 
Hello World!
); 

3. What is state in React?

State is a JavaScript object used to represent the data held in a React app that may change over time. For example, you might have a state variable called clicks which updates when a button is pressed.

State is fully contained within the component, unlike props. In class components, you use the state class variable to set a state variable, like in the example below:

class User extends React.Component { constructor(props) { super(props)
this.state = { greeting: 'Hello World!' } 
}
render() { return ( 
{this.state.greeting}
) } } 

In functional components, you can set state in the component with the useState hook:

const User = () => { const [greeting, setGreeting] = '';
setGreeting('Hello World!');
return ( 
{this.state.greeting}
); } 

4. What are props in React?

Props are inputs for components and a way for passing data from one component to a child component. They can be single values, objects, or functions. Here’s an example:

const User = () => { const [greeting, setGreeting] = '';
setGreeting('Hello World!');
return ( 
); } 

In the example above, the MyHeader component is passed the greeting prop and can be accessed inside that component with props.greeting.

5. What are the three main phases of a React component’s lifecycle?

They are:

  1. The initial rendering phase, when the component is about to modify the DOM of the web page.
  2. The updating phase after the component is added to the DOM and only updates when its state or props change.
  3. The unmounting phase, when the component is destroyed and removed from the DOM.

6. What are synthetic events in React?

React wraps the native events of the browser with its own event structure for cross-browser compatibility. It has the same API as the browser’s events but acts the same in every browser.

7. Where is using a key prop necessary, and why?

Key props are required when you create an array of elements. React uses this key to identify specific elements in the array when they’re updated, removed, or added.

8. What is a ref in React?

A ref (reference) in React is an attribute that gives you a handle to access the functions in a specific element. Here’s an example:

const User = () => { const ref = React.useRef();
ref.current.focus();
return ( 
); } 

The code above will focus the cursor in the input using a ref.

9. What are Higher-Order Components (HOC)?

Higher-Order Components are custom components that wrap other components within them. They can dynamically accept one or more components as children without modifying or copying any of the children’s behavior. They allow for code reuse and state abstraction and manipulation.

10. What are pure components?

Pure components in React don’t re-render when props or states update to the same value. You can extend the React.PureComponent class to use them. The rendering is restricted in this way for higher performance and is often used for components that are mainly for display.

Learn more about React

Don’t worry about preparing for every possible question you might face during your interview. That’d be impossible. Instead, focus on solidifying your understanding of React concepts and functions, and if you need a refresher, try courses like:

But remember, even if the company you’re interviewing with relies heavily on React, they’ll likely test your knowledge of other programming tools and functions. You might even be asked to complete a technical interview. For more information on interviewing in the tech industry, check out the articles below. Then, for more tips on how to prepare, visit our Career Center.


Interview Prep Courses & Tutorials | Codecademy

Interviewing is an important step in your journey towards landing a job in tech. Technical interviews let you showcase your skills and knowledge, but practice is key. You’ll need to understand technical concepts and be prepared to talk through solutions with your interviewers.

Candy Cornucopia

0
Candy Cornucopia

Use your imagination to write the opening of a short story or poem inspired by this photograph — or, tell us about a memory from your own life that this image makes you think of.

Post it in the comments, then read the related article to learn more.


Want more Picture Prompts? Find them all in this column.

Students 13 and older in the United States and Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.

Word of the Day: malleable

0
Word of the Day: malleable

1. capable of being shaped or bent or drawn out

2. easily influenced

_________

The word malleable has appeared in 57 articles on NYTimes.com in the past year, including on Jan. 6 in “Watching a Partner Change Is Hard. Accepting It Can Be Harder.” by Allison Hope:

We don’t marry one person as much as we marry one version of a person, a snapshot of who we (and our partner) are individually and to one another at the moment when we say “I do.” Who we are five, 10 or 40 years later is anybody’s guess.

People change. As a result, relationships change, too.

“Not only do relationships change with time, but people change, which can affect the relationship dynamics as well,” said Michelle Chalfant, a therapist in Charlotte, N.C.

Personalities are more malleable than we may think. Most of us change, though often gradually, according to a study published in 2018 by the University of Houston, University of Tübingen and University of Illinois at Urbana-Champaign, which assessed the personality traits of 1,795 people in the U.S. in adolescence and then 50 years later. Many participants, the study showed, tended to become more emotionally stable, conscientious and agreeable over time.

Can you correctly use the word malleable in a sentence?

Based on the definition and example provided, write a sentence using today’s Word of the Day and share it as a comment on this article. It is most important that your sentence makes sense and demonstrates that you understand the word’s definition, but we also encourage you to be creative and have fun.

Then, read some of the other sentences students have submitted and use the “Recommend” button to vote for two original sentences that stand out to you.

If you want a better idea of how malleable can be used in a sentence, read these usage examples on Vocabulary.com.

Vocabulary in Context: Exotic Pets

0
Vocabulary in Context: Exotic Pets

There are several reasons a person might come to own a large number of unusual pets. For instance, because they are passionate about animals. But also, because YouTube is passionate about animals — the more, the better. “A large number of pets is not my goal, but a large number of pets gets views on YouTube,” Pasiecznik said.

At the moment, Pasiecznik has 31 animals (his cockroach and powder orange isopod colonies are too unwieldy to calculate as individuals, so he counts each colony as one pet). This is a relatively number for him. His most popular videos of all time include “Feeding my 31 tarantulas (GONE WRONG)” (3.7 million views), “FEEDING ALL MY ANIMALS (100+ PETS) [INSANE]” (1.6 million views) and the Spanish-language version of that video, “ALIMENTANDO A TODOS MIS ANIMALES (+100 MASCOTAS) INCREÍBLE” (1.8 million views).

Lesson of the Day: ‘What It’s Like to Leave Prison During a Pandemic’

0
Lesson of the Day: ‘What It’s Like to Leave Prison During a Pandemic’

FADE IN

Night driving empty road ahead. Carlos driving at night.

Carlos (VO)
Every ride home is different. A lot of times when I feel like I’m used to getting up in the morning and driving, three, four hours into these prisons, the middle of nowhere, to pick up another lifer. I figured I’d be used to it by now, but I’m not.

Car dashboard and car clock

TEXT CARD
Carlos works with a ride home program started after California reformed Three Strikes – and made thousands eligible for release.

Carlos (VO)
Knowing that I’m picking someone up that just finished doing 25 years, kinda takes me to how I felt back in 2002 when I was there.

Carlos arrives at the prison gates
Good morning, Sir. We’re here to pick up Mr. Stanley Bailey.
Guard
From Ironwood, or?
Carlos
From Ironwood, yes.
Guard
You’ll just pull over here, wait over here.
Carlos
Perfect

Carlos on camera
When I was incarcerated, I was a teenager, 16 at the time. I took a 12-year plea bargain for an attempted murder. Ended up doing 10 years and 8 months. I got released when I was 27. And I’m looking at the world to kinda find that release for my brothers and sisters that are still locked up.

Carlos waits in the twilight, staring toward the prison in the distance

Carlos (VO)
Being able to help someone makes me grateful. It’s like a privilege, like an honor.

Carlos waits… The sun rises, time passes… Birds fly in circles toward the sky…

VERITE: STANLEY and CARLOS greet one another
Carlos
Stanley, what’s up?
Stanley
Thanks for the ride.
Carlos
You ready or what?
Stanley
Yeah, more than ready
Carlos
Welcome home.
Stanley
Thank you.

Carlos/Stanley get in the car and drive off
Carlos
We’re gonna try and take care of the first few hours at the very least.
Stanley
I appreciate that, thank you.

TEXT CARD
Stanley is among dozens of “lifers” Carlos has picked up from prisons throughout the state.

Carlos and Stanley drive.

Carlos (VO)
When I do this, it’s open heartedly. I don’t know who that person is, why he’s getting out, why he was arrested, why he did all that time. But saying “you know what, regardless of what happened I’m here.”

Carlos (VO)
Most of the guys that get out have families that are deceased. Most of them don’t have friends anymore. A lot of these guys are actually scared. Their biggest fear is to fail.

Stanley (VO)
You know, I’m not young anymore. I gotta start a whole new career. So I’m pretty much starting from scratch. I’m gonna have my hands full just getting on my feet.

Carlos driving
It comes with the territory you know…when I got out I had a pretty heavy burden on my shoulders. You know, I had already…I had to pay rent. And then, not having like, someone to really talk to and could relate, that… that…just tore me down.

Carlos
The fear of going back, the fear of saying, you know, “this is a revolving door for you“. Being institutionalized. The emotions that you go through, you don’t know how to deal with them. You always try to isolate yourself. Sometimes I feel like I’m still institutionalized. I used to go in the bathroom, take a shower, and I used to just cry. I didn’t know how to deal with it.

The road ahead, Carlos and Stanley walk through Joshua Tree

VERITE Stanley

Of all the things that everybody talked about doing when I got out, I told them, ’ Hey, I just want to sit on the grass under a tree’. I haven’t been under a tree in, y’know, 25 years.

CARLOS and STANLEY CONTINUE WALKING THROUGH DESERT…

VERITE Stanley
It’s beautiful out here. I don’t have any time to waste on jail anymore.

Carlos driving, road ahead, Stanley looking out window.

Driving POV – Los Angeles Skylike and Streets.

Stanley on the side of the street.

VERITE Stanley
Yeah, this is gonna take some getting used to.

VERITE Stanley
It’s real uncomfortable. It’s gonna take a minute. I haven’t had a car go by me in almost 30 years.

Carlos and Stanley at a diner.

Carlos (VO)
I think it’s therapeutic for me. Releasing some of that information that I know and teaching them kinda how it’s gonna be. How do you want this to end up? How do you want to continue living your life? Within those first 24 hours if you don’t have the support necessary or the belief in yourself that’s necessary for you to continue on, then you’ll struggle.

Establishing shots of Amity, Stanley walks into the building, greeted by others.

Amity resident 1
Comin’ out, it’s a lot of pressure. When I first got out I was scared. I’m not gonna lie, I was terrified.

Amity Resident 2
We give hope to other people that are behind the walls still just waiting to come out and we make this a safe place for people to transition to society. Welcome to your house, because this is gonna be your house.

Carlos hugs and welcome Stanley.

Scenes around Amity.

Carlos (VO)
Three days ago, he was a lifer. His mentality was as a lifer and a lifer is I’m spending the rest of my life in prison. And then all of the sudden boom, you’re out. The $200 they give you as gate money and for them to say “OK, go live a life, go try to make it.” People never see the potential in someone, they figure that we could categorize them as they were. They are prisoners, they’re inmates, that’s what they are.
When we talk about throw away the key, lock ‘em up.
We don’t give people enough opportunities. I think that’s our biggest problem.

TEXT CARD
More than half a million people are released from prison each year in the United States.

CREDITS

Is It Bad Sportsmanship to Run Up the Score in Youth Sports?

0
Is It Bad Sportsmanship to Run Up the Score in Youth Sports?

Have you ever participated in a blowout? In baseball, 23-2. In football, 68-13. A game with a score so wildly lopsided that the outcome of the game was almost never in doubt — and the contest never seemed to mercifully end. Have you ever watched a game like this?

How should coaches and teams handle a blowout, especially in youth sports? Should a “mercy rule” automatically end games early? Should teams be forced to bench starters? Should players stop trying to score? Should coaches be suspended? Or should we accept wildly lopsided scores as part of the nature of athletic competition?

In “A School Won 92-4 in Basketball. Then the Coach Was Suspended,” Neil Vigdor writes about a high school coach in Connecticut who was suspended after his team won by 88 points:

The scoreboard, stuck on zero for the visiting team until the game’s final quarter, wasn’t broken.

The full-court pressure and man-to-man defense had been just that suffocating. Just as unrelenting were the barrage of three-point shots and fast-break chances.

But the lopsided result of the high school girls’ basketball game in Connecticut this week might have made even Bobby Knight blanch — the final score between Sacred Heart Academy and Lyman Hall High School was 92-4.

Now the coach of Sacred Heart, a Roman Catholic high school for girls in Hamden, Conn., near New Haven, has been suspended for one game by the school’s administration, which apologized for the manner in which “the outcome of the game was achieved” on Monday night.

The suspension of Jason Kirck, the third-year coach of the Sharks, one of the top-ranked teams in the state, was confirmed on Thursday by Al Carbone, the commissioner of the Southern Connecticut Conference. Sacred Heart won the league’s Division 2 championship last year.

“It raises a red flag,” Mr. Carbone said on Thursday of the score. “It’s not just it was an 88-point margin. How does it impact our student-athletes?”

It wasn’t the first time that a scholastic sports program had drawn criticism for running up the score on an opponent and prompted a debate over the boundaries between athletic prowess and sportsmanship.

Students, read the entire article, then tell us:

  • Should blowouts be allowed in youth sports? Are wildly lopsided scores unsportsmanlike? Or are blowouts inevitable, and even necessary, in any form of athletic competition? Where do you draw the line in the “debate over the boundaries between athletic prowess and sportsmanship”?

  • Have you ever participated in a blowout game — whether as the victor or the vanquished? If yes, tell us about your experience. How did you feel at the time? Does reading the article change how you view that experience?

  • What’s your reaction to the final score of the Sacred Heart Academy and Lyman Hall High School basketball game? Do you think the coach, Jason Kirck, should have been suspended? The coach at Lyman Hall, Tom Lipka, told news outlets that Sacred Heart kept trying to force turnovers and never relented with its fast-break offense. What do you think of this strategy, even with an insurmountable lead?

  • In a statement, Sister Sheila O’Neill, Sacred Heart’s president, said: “Sacred Heart Academy values the lessons taught and cultivated through athletic participation, including ethical and responsible behavior, leadership and strength of character and respect for one’s opponents. Last night’s Girls’ Basketball game vs Lyman Hall High School does not align with our values or philosophies.” Is it important to teach ethical and responsible behavior in all youth sports teams and programs along with athletic skills? Do you think more schools should take a principled stance for sportsmanship, as Sacred Heart did?

  • The Hartford Courant newspaper commended Sacred Heart for apologizing, writing, “the game needs to serve as an example for adults and students alike that winning isn’t everything.” Do you agree? Are blowouts always a bad thing? What life lessons — good or bad — do blowout games teach the young people who participate in them? What lessons are taught if you eliminate them?

  • If you were a commissioner of a youth league, what guidelines and policies would you put in place around this issue? What life lessons and kinds of sportsmanship would you want to instill and encourage?


Want more writing prompts? You can find all of our questions in our Student Opinion column. Teachers, check out this guide to learn how you can incorporate them into your classroom.

Students 13 and older in the United States and Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.

Coursera partners with K-MOOC and the National Institute for Lifelong Education to upskill 200,000 learners in South Korea

0
Coursera partners with K-MOOC and the National Institute for Lifelong Education to upskill 200,000 learners in South Korea

By Leah Belsky, Chief Enterprise Officer

The double disruption of automation and the pandemic is rapidly reshaping labor markets globally. These forces have accelerated the Fourth Industrial Revolution in South Korea and around the world, and institutions are aligning their efforts to prepare workers for the digital economy. 

The unemployment rates in South Korea reached a record low in August 2021, according to recent government data. However,  the percentage of people either working or actively looking for work is 63%. People working less than 36 hours per week increased approximately 65% from a year earlier, and those workers are mostly in lower paying and less desirable roles. As technology evolves at an accelerated rate, employers increasingly value professionals with new digital skills and a strong growth mindset. 

I’m excited to announce that Coursera is partnering with K-MOOC and the National Institute for Lifelong Education (NILE) to launch a nationwide upskilling program in South Korea. The initiative will help over 200,000 adult learners develop the high-demand digital skills needed to advance their education and careers in the new economy and embrace lifelong learning amid rapid transformation. 

“Our collaboration with Coursera will be an important starting point for expanding the learning landscape of Korean learners to the world,” Dae joong Kang, NILE President. “When mapping out the post-pandemic future, online learning will become an increasingly expected and popular learning avenue for adult learners. And, I expect Coursera’s excellent courses will equip our learners with new and high-demand digital skills needed to thrive in the Fourth Industrial Revolution.” 

Through this partnership, learners across Korea will have access to 70 job-relevant, Korean-language courses from top university and industry leaders worldwide, including Yale University, University of Pennsylvania, Google and DeepLearning. AI. The initiative, supported by the Ministry of Education, aims to equip students, graduates, school and university educators, as well as middle- and late- career professionals with the professional and digital skills needed for jobs of the future. 

With a best-in-class IT infrastructure and the prioritization of education, South Korea has the opportunity to unlock economic potential for learners across the country by enabling access to high-quality, online learning across in-demand fields such as data science, technology, business, and personal development. 

Coursera has over 540,000 registered learners in South Korea, a 25% increase from the previous year. Our partnership with K-MOOC and NILE is a testament to our ongoing commitment to help learners across the country prepare for the rapidly-changing skills and employment landscape. Investing in the right skills for students and professionals may help build an agile, competitive workforce of lifelong learners that can usher in long-term growth and prosperity. 

Level Up Your Web Dev Skills by Connecting Front-End to Back-End

0
Level Up Your Web Dev Skills by Connecting Front-End to Back-End
Level Up Your Web Dev Skills by Connecting Front-End to Back-End

Full-Stack Developers know how to build the front end of a website, the back end, and everything in between. And, if you’re looking for a career in web development, you should, too.

In our new course, Connecting Front-End to Back-End, we’ll introduce you to the technologies that allow the two to communicate. You’ll explore the differences between client- and server-side rendering, create your own RESTful APIs (APIs that conform to REST standards), and learn how to organize your code with MVC (Model, View, Controller) architecture.

Who is it right for?

If you’ve been learning about front-end or back-end development and want to learn more about how the two interact, this is the course for you. The same goes for those looking to optimize their web apps and offer a more seamless experience for their users. As Jiwon Shin, one of the Curriculum Developers behind our new course, explains:

“Learning the difference between client-side and server-side rendering will help you make informed decisions as to which rendering method you should go with to suit the needs of your web apps. Plus, MVC architecture can help you restructure existing web pages to achieve modularity through separation of data representation, logical, and presentation layers.”

Plus, REST standards and MVC architecture are ubiquitous in the tech industry, so getting familiar with both can help give you an edge in your job search.

What will you learn from the new course?

In the new course, you’ll learn all about REST APIs and MVC architecture while building a client-side rendered app with React and Node.js. That means, along with Node and React, you’ll also need to be familiar with HTML, CSS, and JavaScript. Bonus points if you’ve taken our Design Databases With PostgreSQL Skill Path, but it’s not required.

By the end of Connecting Front-End to Back-End, you’ll be able to:

  • Write code that enables the front end and back end to communicate
  • Connect front end to back end using REST APIs
  • Implement MVC architecture for full-stack web apps
  • Identify the differences between client- and server-side rendering

Ready to become a better Web Developer? Start by Connecting Front-End to Back-End.


Web Development Courses & Tutorials | Codecademy

Web Development is the practice of developing websites and web apps that live on the internet. Whether you’re interested in front-end, back-end, or going full-stack, the content in our Web Development domain will help you get there.

Add Emotion to Your Web Apps With CSS-in-JS

0
Add Emotion to Your Web Apps With CSS-in-JS
Add Emotion To Your Web Apps With CSS-in-JS

January is National Creativity Month, and what better way to showcase your creativity than by giving your web apps some style? Want to learn how? We’ll show you in our new course: Learn CSS-in-JS.

In this course, you’ll learn how to add CSS styles to your web app using JavaScript syntax. If you already have a strong background in web development and you’re looking to pick up some new tricks — now’s the time! Jiwon Shin, one of the Curriculum Developers behind our new course, explains that the benefits of using CSS-in-JSS include:

  • No more switching between JavaScript and CSS to write styling
  • Automatic inlining of critical-path CSS
  • No class names and IDs collisions — every class name and ID is guaranteed to be unique
  • Automatic vendor prefixing
  • Reducing code and file size since compiled CSS only includes necessary declarations

Plus, as you discover a new way of implementing CSS, you’ll also learn how to use the Emotion library, which has been gaining traction in the tech industry and is currently used by companies like Reddit and Patreon.

Who is the course right for?

Learn CSS-in-JS is well-suited for learners who’ve mastered the basics of web development (including HTML, CSS, and JavaScript), along with React, and want to expand on their web design skills. Plus, if you’re looking for work as a Front-End or Full-Stack Developer, getting hands-on experience with CSS-in-JS and Emotion can help give you an edge in your job search.

What will you learn from the new course?

In Learn CSS-in-JSS, you’ll use the styling technique to build a React web application, following a tutorial as you go along. By the end of the course, you’ll be able to:

  • Explain the pros and cons of using CSS-in-JSS.
  • Identify different CSS-in-JSS libraries.
  • Use Emotion in an existing React app.
  • Apply styles to a React app using the CSS-in-JSS syntax.

Ready to learn a new way to use CSS? Check out Learn CSS-in-JS!


Web Development Courses & Tutorials | Codecademy

Web Development is the practice of developing websites and web apps that live on the internet. Whether you’re interested in front-end, back-end, or going full-stack, the content in our Web Development domain will help you get there.

What’s Going On in This Graph? | Jan. 19, 2022

0
What’s Going On in This Graph? | Jan. 19, 2022

4. After you have posted, read what others have said, then respond to someone else by posting a comment. Use the “Reply” button to address that student directly.

On Wednesday, Jan. 19, teachers from our collaborator, the American Statistical Association, will facilitate this discussion from 9 a.m. to 2 p.m. Eastern time.

5. By Friday morning, Jan. 21, we will reveal more information about the graph, including a free link to the article that includes this graph, at the bottom of this post. We encourage you to post additional comments based on the article, possibly using statistical terms defined in the Stat Nuggets.

We’ll post more information here on Thursday afternoon. Stay tuned!


More?

See all graphs in this series or collections of 60 of our favorite graphs, 28 graphs that teach about inequality and 24 graphs about climate change.

View our archives that link to all past releases, organized by topic, graph type and Stat Nugget.

Learn more about the notice and wonder teaching strategy from this 5-minute video and how and why other teachers are using this strategy from our on-demand webinar.

Sign up for our free weekly Learning Network newsletter so you never miss a graph. Graphs are always released by the Friday before the Wednesday live-moderation to give teachers time to plan ahead.

Go to the American Statistical Association K-12 website, which includes teacher statistics resources, Census in the Schools student-generated data, professional development opportunities, and more.

Students 13 and older in the United States and the Britain, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.