21.How do you tell react to build in production mode and what will that do?
Ordinarily you’d utilize webpack’s defineplugin strategy to set node_env to production. This will strip out things like proptype approval and additional notices. Over that, it’s likewise a smart thought to minify your code in light of the fact that react utilizes uglify’s dead-code end to strip out advancement just code and remarks, which will radically diminish the measure of your package.
22. List some of the cases when you should use refs.
Following are the cases when refs should be used:
- When you need to manage focus, select text or media playback
- To trigger imperative animations
- Integrate with third-party dom libraries
23.What are Higher Order Components(HOC)?
Higher Order Component is an advanced way of reusing the component logic. Basically, it’s a pattern that is derived from React’s compositional nature. HOC are custom components which wrap another component within it. They can accept any dynamically provided child component but they won’t modify or copy any behavior from their input components. You can say that HOC are ‘pure’ components.
24.How do you apply vendor prefixes to inline styles in react?
React does not apply vendor prefixes automatically. You need to add vendor prefixes manually.
<div style={{
Transform: ‘rotate(90deg)’,
Webkittransform: ‘rotate(90deg)’, // note the capital ‘w’ here
Mstransform: ‘rotate(90deg)’ // ‘ms’ is the only lowercase vendor prefix
}} />
25. What do you know about controlled and uncontrolled components?
Controlled vs uncontrolled components |
|
Controlled components | Uncontrolled components |
1. They do not maintain their own state | 1. They maintain their own state |
2. Data is controlled by the parent component | 2. Data is controlled by the dom |
3. They take in the current values through props and then notify the changes via callbacks | 3. Refs are used to get their current values |
REACT JS & CERTIFICATION
Weekend / Weekday Batch
26.What are Pure Components?
Pure components are the simplest and fastest components which can be written. They can replace any component which only has a render(). These components enhance the simplicity of the code and performance of the application.
27. What are higher order components(hoc)?
Higher order component is an advanced way of reusing the component logic. Basically, it’s a pattern that is derived from react’s compositional nature. Hoc are custom components which wrap another component within it. They can accept any dynamically provided child component but they won’t modify or copy any behavior from their input components. You can say that hoc are ‘pure’ components.
28.What are the main features of react intl?
- Display numbers with separators.
- Display dates and times correctly.
- Display dates relative to “now”.
- Pluralize labels in strings.
- Support for 150+ languages.
- Runs in the browser and node.
- Built on standards.
29.How to add google analytics for react router?
Add a listener on the history object to record each page view:
History.listen(function (location) {
Window.ga(‘set’, ‘page’, location.pathname + location.search)
Window.ga(‘send’, ‘pageview’, location.pathname + location.search)
})
30.What can you do with hoc?
Hoc can be used for many tasks like:
- Code reuse, logic and bootstrap abstraction
- Render high jacking
- State abstraction and manipulation
- Props manipulation