ReactJS Test Upwork

_____ function is used for attaching event listeners on markup rendered by ReactDOMServer.

ReactDOMServer.attachEventListeners
ReactDOMServer.processRenderedMarkup
ReactDOM.hydrate
ReactDOM.attachEventListeners\

What programming concept does React use for DOM manipulation and updating?

ReactDOM
Virtual DOM
Shadow DOM

What is the name of a pseudo-global variable that determines whether the environment is development or production?

NODE_ENV
isProd
__DEV__

How can you stop event propagation in React? (Check all that apply.)
Note: There may be more than one right answer.

With stopPropagation function.
With preventDefault function.
Returning false from the event handler.
All of the above.

How can SyntheticEvent be stopped?
Note: There may be more than one right answer.

You can't stop it. It will be fired for all parent components.
Return false from event handler.
Fire stopPropagation on event object.
Fire preventDefault on event object.

What is a purpose of shallow rendering in React?

For production build.
For unit testing.
For server side rendering.
All of the above.

Jest and Enzyme are suggested libraries for what purpose?

Flux architecture
Testing
Animations
Styling

What are the correct ways of creating a ref in React? (Check all that apply.)
Note: There may be more than one right answer.

render() {
    return <div ref={element => this.refs.elementRef = element} />;
}

render() {
    return <div ref='elementRef' />;
}

constructor(props) {
    super(props);
    this.elementRef = React.createRef();
}
render() {
    return <div ref={this.elementRef} />;
}

constructor(props) {
    super(props);
    this.elementRef = null;
}
render() {
    return <div ref={element => this.elementRef = element} />;
}

All of the above

Which of the following are valid properties of the React router's route component? (Check all that apply.)
Note: There may be more than one right answer.

Component
Path
Url
Render
Value

What is the difference between ReactDOMServer's renderToString and renderToStaticMarkup functions?

renderToString creates extra DOM attributes while renderToStaticMarkup does not.
renderToString is available in server only while renderToStaticMarkup is available in a browser too.
renderToString returns DOM as a string while renderToStaticMarkup returns JSX markup.

How can type checking in React be done? (Check all that apply.)
Note: There may be more than one right answer.

Using static type checkers like Flow and TypeScript.
Using PropTypes.
Using the typeof operator.
All of the above.

Can you return multiple elements from a single component?

No
Yes, but you cannot separate them with a line break.
Yes, but you must use React Fragment.
Yes, but you must write them in an array.

What is a recommended way of sharing data between multiple components? (Check all that apply.)
Note: There may be more than one right answer.

Using context.
Using flux architecture.
Declaring global variables.
Passing props from a parent component.
All of the above.

____ is the flux architecture component that receives actions and broadcast payloads to registered callbacks.

Reducer
Dispatcher
Store
Redux

How can you bind a function to a component instance? (Check all that apply.)
Note: There may be more than one right answer.

By using .bind(this) in constructor.
By declaring function as a class property.
By using Autobind annotation.
By declaring a function in a constructor.

Can you render children components outside of a parent component?

Yes
No

Which of following is true about componentWillReceiveProps and getDerivedStateFromProps? (Check all that apply.)
Note: There may be more than one right answer.

Both can access the component instance.
getDerivedStateFromProps is called before the first render while componentWillReceiveProps is not.
You can change props in these functions.
getDerivedStateFromProps is called every time props change while componentWillReceiveProps is called only on initialization.
You must call this.setState in componentWillReceiveProps in order to update the component state.

Can you access refs at a wrapped component in higher-order component technique?

Yes
No

What happens when an error is not caught by the error boundary?

The error message gets rendered below component.
The whole application breaks.
React tries to restore the previous state of a component.
The whole React component tree gets unmounted.

How you can provide an initial value for uncontrolled input?

With the "value" attribute.
With "initialValue" attribute.
With "defaultValue" attribute.

What is a result of the following code?
class ClickCount extends Component {
constructor(props){
    super(props);
    this.state = {
        clickCounter: 0
    }
}
render() {
    <div>
        <p>You clicked {this.state.clickCounter} times.</p>
        <button onClick={this.setState({clickCounter: this.state.clickCounter+1})}>Click me!</button>
    </div>
}
}

The component that counts clicks on a button and displays it in a paragraph.
Infinite re-render error.
Error on button click.

What will be the value of 'a' in the below sample code?
`<MyTextBox a  />`

`a` will have value of `undefined`
`a` will have value of `true`
`a` will have value of `false`
`a` will have value of `null`
None of the above

How do you add a default property to a component?

var DefaultComp = React.createClass({
getDefaultProps : function(){
return {
name : «Mike»
}
}
render : function(){
return (
<h1>Hello {this.props.name}</h1>
)
}
});

var DefaultComp = React.createClass({
getDefaultProps : function(){
return {
name = «Mike»
}
},
render : function(){
return (
<p>Hello {this.props.name}</p>
)
}
});

var DefaultComp = React.createClass({
getDefaultProps : function(){
return {
name : «Mike»
}
},
render : function(){
return (
<p>Hello {this.props.name}</p>
)
}
});

How to set css class on div in ReactJs component?
Note: There may be more than one right answer.

<div className="name" />
<div class="name" />
<div class={'name'} />
<div className={'name'} />
<div cssClass={'name'} />
<div ngClass={'name'} />
<div rClass={'name'} />

In controlled components, which is the correct way to select multiple values using the select drop-down?

<select defaultValue={["lahore", "london"]}, multiple=>(true)>
        <option value="lahore">welcome lahore!</option>
        <option value="london">welcome london!</option>
        <option value="toronto">welcome toronto</option>
 </select>

<select defaultValue={["lahore", "london"]} multiple={true}>
        <option value="lahore">welcome lahore!</option>
        <option value="london">welcome london!</option>
        <option value="toronto">welcome toronto</option>
 </select>

<select defaultValue={["lahore", "london"]} multiple=(true)>
        <option value="lahore">welcome lahore!</option>
        <option value="london">welcome london!</option>
        <option value="toronto">welcome toronto</option>
 </select>

<select defaultValue=>{["lahore", "london"]} multiple=true>
        <option value="lahore">welcome lahore!</option>
        <option value="london">welcome london!</option>
        <option value="toronto">welcome toronto</option>
 </select>

What is the correct value of the children proptype?
propTypes: {
     children: React.PropTypes.string.isRequired
  }

12
['test', 'test2']
99.66
'test1'

 Which code snippet allows you to set a value on a button click event?

class App extends React.Component{
  constructor(){
    super();
    this.state ={data: 'testing'};
  }
  buttonClick(){
   this.setState({data: 'Mjhos'});

this.setState = {data: [] }
  }
  render(){
    return <div>
      <button onClick={this. buttonClick.bind(this)}>Click Me!</button>
</div>
  }
}
React.render(<App/>,document.getElementById('app'))

class App extends React.Component{
  constructor(){
    super();
    this.state ={data: 'testing'};
  }
  buttonClick(){
   this.setState{data: 'Mjhos'};
  }
  render(){
    return <div>
      <button onClick={this. buttonClick.bind(this)}>Click Me!</button>
</div>
  }
}
React.render(<App/>,document.getElementById('app'))

class App extends React.Component{
  constructor(){
    super();
    this.state ={data: 'testing'};
  }
  buttonClick(){
   this.setState(data: 'Mjhos');
  }
  render(){
    return <div>
      <button onClick={this. buttonClick.bind(this)}>Click Me!</button>
</div>
  }
}
React.render(<App/>,document.getElementById('app'))

class App extends React.Component{
  constructor(){
    super();
    this.state ={data: 'testing'};
  }
  buttonClick(){
   this.setState({data: 'Mjhos'});
  }
  render(){
    return <div>
      <button onClick={this. buttonClick.bind(this)}>Click Me!</button>
</div>
  }
}
React.render(<App/>,document.getElementById('app'))

Which of the following code syntax is True in createClass?

class MyComponent extends React.Component {
  render () {
    return <div />;
  }

var MyComponent = React.createClass({
  render: function () {
    return <div />;
  }
});

var MyComponent = React.createClass(
   render () {
    return <div />;
  }
}

class MyComponent extends React.Component ({
  render: function () {
    return <div />;
  }
});

Which of the following is a correct JSX code?

<button onclick="activate()" />
<button onclick="activate()">Activate</button>
<button onClick={activate}>Activate</button>
<button onclick={activate}>Activate</button>

How set custom html inside ReactJs component?

<div dangerouslySetInnerHTML={{__html: 'Some custom html'}} />
<div dangerouslySetInnerHTML={'Some custom html'} />
<div innerHTML={'Some custom html'} />
<div innerHTML={{__html: 'Some custom html'}} />
<div innerHTML={{html: 'Some custom html'}} />
<customHtml>Some custom html</customHtml>
<dangerouslySetInnerHTML>Some custom html</dangerouslySetInnerHTML>

Which is the correct way to add styles for react elements?

<p style={{color: 'red'}}>Paragraph</p>
<p this.style={{color: 'red'}}>Paragraph</p>
<p this.bind.style(this)={{color: 'red'}}>Paragraph</p>
<p stylesheet={{color: 'red'}}>Paragraph</p>

How write comments in JSX code?

// your comment
<!-- your comment -->
{/*your comment*/}
{// your comment}
{<!-- your comment -->}
/*your comment*/

How can you create React Component using the following code snippet?

var Component_Id = React.createClass{
            render: function() {
                return <div>React Component works!</div>;
        }
};
React.render(
<div>     
    <Component_Id />
    <Component_Id />
</div>
, document.getElementById('react-container'));

var Component_Id = React.createClass({
            render: function() {
                return <div>React Component works!</div>;
        }
});
React.render(
<div>     
    <Component_Id />
    <Component_Id />
</div>
, document.getElementById('react-container'));

var Component_Id = React.createClass(
            render: function() {
                return <div>React Component works!</div>;
        }
);
React.render(
<div>     
    <Component_Id />
    <Component_Id />
</div>
, document.getElementById('react-container'));

var Component_Id = React.createClass extends component ({
            render: function() {
                return <div>React Component works!</div>;
        }
});
React.render(
<div>     
    <Component_Id />
    <Component_Id />
</div>
, document.getElementById('react-container'));

When use React.PureComponent?

Instead of calling shallow compare function while counting if component should update after props or state change
While using ES5 and writing pure function component
It's globally available constant to check if component is pure, used to find unoptimized components
It's locally available constant to check if component is pure, used to find unoptimized components

Is it possible to create ReactJS components without JSX?

Yes
No
Yes, but it will require Babel included
Only if it's functional component

Which of the following methods initiates custom state for the component?

getDefaultProps
getInitialState
getState
getDefaultState

Referencing context in lifecycle methods, the following lifecycle methods will receive an additional parameter in the context object? (check all that apply)
Note: There may be more than one right answer.

componentDidUpdate(nextProps, nextState, nextContext)
componentWillReceiveProps(nextProps, nextContext)
componentWillUpdate(nextProps, nextState, nextContext)
shouldComponentUpdate(prevProps, prevState, prevContext)

Which of the following Lifecycle Methods does React include?
Note: There may be more than one right answer.

ComponentWillMount
ShouldComponentUpdate
ComponentDidUnmount
ComponentWillUpdate
All of the above

How can you create ReactJs component?

With pure JS functions
JS functions, ES6 classes extending React.createClass or React.Component function
JS functions, ES6 classes extending React.Component or React.createClass function
JS functions, ES6 classes extending React.Component or React.createClass function, but then you can't defined initial state
If initial state is needed only with ES6 classes extending React.Component, otherwise - with pure JS functions or React.createClass function
With ES6 Classes if using Babel, or with JS functions

How do you add a default property to a component?

var DefaultComp = React.createClass({
getDefaultProps : function(){
return {
name : «Mike»
}
}
render : function(){
return (
<h1>Hello {this.props.name}</h1>
)
}
});

var DefaultComp = React.createClass({
getDefaultProps : function(){
return {
name = «Mike»
}
},
render : function(){
return (
<p>Hello {this.props.name}</p>
)
}
});

var DefaultComp = React.createClass({
getDefaultProps : function(){
return {
name : «Mike»
}
},
render : function(){
return (
<p>Hello {this.props.name}</p>
)
}
});

var DefaultComp = React.createClass({
getDefaultProps : function(){
return {
name => «Mike»
}
},
render : function(){
return (
<h1>Hello {this.props.name}</h1>
)
}
})

Which of the following method is called after getInitialState method?

componentWillMount
componentDidMount
getDefaultProps
render

Can you use ReactJs with AngularJs on same web application?

No, because both are using virtual DOM
Yes
No, because you can have only one view layer related library per project while using webpack, babel or browserify
No, because ReactJs will re-render all html after initial load

How to set ReactJS global configuration?

React.configure
React.register
ReactJs does not provide global configuration
React.setConfig

What is true about context inside a component?

Context is no longer available anywhere in ReactJs app
nextContext can be accessed at shouldComponentUpdate
Context is not available in the constructor
None of the above

Which  function is invoked just  before render() during initial rendering?

componentDidMount()
componentBeforeOccur()
componentWillReceiveMount()
componentWillMount()

Which of the following functions belong to ReactDOM? (Check all that apply)
Note: There may be more than one right answer.

render()
renders()
getElementById()
findDOMNode()
All of the above

Can a single component render multiple nodes?

Yes
No
Only if all children are wrapped with some node
No correct answer

What is the difference between props and state?

State is similar to props, but it is private and fully controlled by the component.
Props is similar to state, but it is private and fully controlled by the component.
State and props both are similar
None of the above

Which of the following methods enables to set the initial state value, that is accessible inside the component via this.state?

getInitialState
getState
getDefaultProps
getDefaultState

What are the differences between state and props in React? (choose all that apply)
Note: There may be more than one right answer.

The state can be changed by parent Component, while props can't.
The state can change inside Component, while props can't.
The props can't set initial value for child components, while state can.
The props can get the initial value from parent Component, while state not.

The defaultValue and defaultChecked props are only used during initial __?

props
render
state
constructor
Component

PropTypes is used for ___ ?

getInitialState
Validation
getPropsValue
getDefaultProps
typechecking

Which of the following types can be the ReactNode? (choose all that apply)
Note: There may be more than one right answer.

Array of React Nodes, Plain Object, Array of Strings
ReactElement, String, number
Array of React Node
Array of Numbers, Array of Plain Objects, String

Which of the following are correct React PropTypes? Check all that apply.
Note: There may be more than one right answer.

symbol
node
boolean
array
function

Which statement about ReactJs is incorrect?

ReactJs alone can be used to write native applications for Android and iOS
ReactJs can keep state out of the DOM while passing data through application
ReactJs app can be rendered on the server
ReactJs is used by Facebook.com in production
You must know JavaScript to write ReactJs app
ReactJs encourages writing html inside js file

Which statement is valid for ReactDOM.findDOMNode() function?

It can be used anywhere inside the component to get DOM element at any time
It's the recommended way to update DOM by calling on single element
Can be used in class-based or functional components
Will return false if component is not mounted yet
It returns the corresponding native browser DOM element

Which statement about ReacJs is correct?

ReactJs uses MVC pattern to manipulate data flow inside application, that's why it's so easy to build native applications with it
With ReactJs you can write HTML in JS with JSX
With ReactJs you extend HTML with custom ReactJs bindings
ReactJs is a closed source library produced by Facebook and used by many big companies in production: Airbnb, Facebook, Twitter and others
ReactJs is fast because it has no virtual DOM and directly manipulates HTML document with MVC pattern
ReactJs uses flux pattern instead of virtual DOM to manipulate singleton CSS objects

Which of the following correctly explains the term "mounting"?

A component is being inserted into the Virtual DOM.
A component is being removed from the DOM.
A component is being re-rendered.
A component is being inserted into the DOM.

Which of the following are valid properties of the input node in ReactJS?

value
type
ref
defaultValue
All of the above

Which of the following properties are available for a wheel event? (Check all that apply)
Note: There may be more than one right answer.

deltaMode
deltaX
X
No such event
position
x
No correct answer

What are the Component properties? (choose all that apply)
Note: There may be more than one right answer.

this.isMounted
this.props
this.state
this.ref
this.render

What are the Animation Events?  (choose all that follow)
Note: There may be more than one right answer.

onAnimationStop
onAnimationStart
onAnimationEnd
onAnimationIteration

Which of the following is a valid Composition Event?

onKey
onCompositionUpdate
onmousemove
No correct answer

How can you stop event propagation inside event handler? (Check all that apply)
Note: There may be more than one right answer.

Return false
Use `event.preventDefault()`
Use `event.stopPropagation()`
Return true
None of the above

Which of the following are valid component life cycle events? (Check all that apply)
Note: There may be more than one right answer.

componentWillUnmount
componentShallUpdate
componentWillUpdate
componentUpdated

Which of the following will not allow an event to be accessed?

Asynchronous
Synchronous
Both of the above
None of the above

Which event is best used to update state after props were changed?

shouldComponentUpdate
componentReceivedProps
componentWillReceiveProps
componentUpdated
componentWillUpdate
shouldComponentUpdateState
componentDidUpdate
forceUpdate

How can SyntheticEvent  be stopped?

You can't stop it, it will be fired for all parent components
Return false from event handler
Fire stopPropagation on event object
Fire preventDefaults on event objec

Will and if yes, when and how immutable data will make big ReactJs application faster?

Immutable data is one more abstraction layer and it will make application slower, but it will introduce better overall developer experience
For complicated data structure immutable data provides faster comparison
Immutable data won't provide better performance because it requires more CPU cycles and RAM to create new objects on every change
Immutable data use smart history cache when multiple mutations are done for same object, which provides easier shouldComponentUpdate implementation
Immutable data will perform faster because it doesn't create new pointers for every object, like normal objects do
Immutable data will perform better because of abstracting prototype chain for all Object type data structures

Which of the following are true about React Library? (choose all that apply)
Note: There may be more than one right answer.

Make AJAX requests
Update DOM-tree
React on events
Store data

Which value will render nothing? (Check all that apply)
Note: There may be more than one right answer.

null
0
false
undefined
All of the above

Which of the following is the correct data flow in a flux application?

Action->Dispatcher->View->Store
Action->Dispatcher->Store->View
Dispatcher->Action->Store->View
Action->Store->Dispatcher->View
None of the above

Can you use ReactJs without flux?

Yes, but then you will have to use MVC
Yes
No
No, it's in core of ReactJS

What is default css display value for ReactJs web application?

inline
flex
block
browser dependent
none
inherit
inline-block

What visual design guidelines must be used to build web UIs with ReactJs?

None
Material design guidelines
Flat design guidelines
Facebook design guidelines
Twitter design guidelines

What does the acronym JSX mean?

Jquery Syntax Extension
JavaScript Syntax Extension
Javascript Syntax Evaluation
Javascript Specific Extension
JavaScript XML

ReactJS Тест Upwork 2019