06. Side Effects Flashcards

(2 cards)

1
Q

What are side effects in React and how can they affect component output?

A

Side effects are operations that interact with external systems (like browser APIs, remote APIs, or HTML elements).

They can affect component output because they’re used to interact with third-party APIs, measure HTML elements, or work with JavaScript functions like timers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you initiate state from localStorage?

A
const App = () => { 

.. const [searchTerm, setSearchTerm] = React.useState(  localStorage.getItem('search') || 'React' ); 

... );
How well did you know this?
1
Not at all
2
3
4
5
Perfectly