react js linkedin assessment answers
1. What is the name of the compiler used to transform JSX into JavaScript?
- Browser Buddy
- Babel
- ReactDOM
- JSX Editor
2. What is this pattern called?
const [count, setCount] = useState(0);
- spread operating
- code pushing
- array destructuring
- object destructuring
3. This code is part of an app that collects Pokemon. The useState hook below is a piece of state holding onto the names of the Pokemon collected so far. How would you access the collected Pokemon in state?
const PokeDex = (props) => {
const [pokeDex, setPokeDex] = useState ([]);
// ...
}
- this.props.pokeDex
- props.pokeDex
- setPokeDex()
- pokeDex
4. The code below is rendering nothing and generating this error: "ReactDOM is not defined." How do you fix this issue?
- createRoot (document.getElementById ( “root”) ) ;
- renderDOM(document.getElementById(“root”));
- ReactDOM(document.getElementById( “root” ) );
- DOM(document.getElementById(“root”));
5. What does this React element look like?
React.createElement(
"hi",
null,
"What's happening?"
);
- <h1 props={null}>What’s happening?</h1>
- <h1>what’s happening?</h1>
- <h1 id=”component”>What’s happening?</h1>
- <h1 id=”null”>What’s happening?</h1>
6. Which choice will not cause a React component to rerender?
- if the component’s key prop changes
- if the component’s local state changes
- the value of one of the component’s props changes
- one of the component’s siblings rerenders
7. When using a portal, what is the second argument?
ReactDOM.createPortal(x,y)
- the rendered element
- the DOM element that exists outside of the parent component
- the App component
- the current state
8. All React components must act like _____with respect to their props.
- higher-order functions
- recursive functions
- monads
- pure functions
9. You are rendering a list with React when this message appears in the console: "Warning: Each child in a list should have a unique key prop." How do you fix this issue?
- When iterating over the list items, add a unique key prop to each list item.
- Clear the console warnings.
- Use the useId hook to generate a unique key for each element in the list.
- Add a key prop with the same value to each item in the list.
10. Which attribute is React's replacement for using innerHTML in the browser DOM?
- weirdsetInnerHTM
- strangeHTML
- injectHTML
- dangerouslySetInnerHTML
11. What do you need to change about this code to get it to run?
const clock = (props) => {
return <h1>Look at the time: {props.time}</h1>;
};
- Add quotes around the return value.
- Capitalize clock.
- Use an implicit return statement.
- Destructure time off of the props object.
12. What is happening in this code?
const { name: firstName } = props;
- It is assigning the value of the props object’s firstName property to a constant called name.
- It is assigning the value of the props object’s name property to a constant called firstName.
- It is retrieving the value of props.name.firstName.
- It is creating a new object that contains the same name property as the props object.
13. How would you generate the boilerplate code for a new app that you are building to collect underpants?
- react new collect-underpants
- npx create-react-app collect-underpants
- npm create-react-app collect-underpants
- npx start-app collect-underpants
14. Which function from React can you use to wrap Component imports to load them lazily?
- lazy
- fallback
- memo
- split
15. Given this code, what will be printed in the tag?
- It will produce an error saying “cannot read property “length” of undefined.”
- 1
- undefined
- 2