You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+92-8Lines changed: 92 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,13 +189,13 @@ Below is a list of ReactJS interview questions and answers.
189
189
|180|[Why is react component's constructor called once?](#why-is-react-component's-constructor-called-once)|
190
190
|181|[How to define constants in reactjs?](#how-to-define-constants-in-reactjs)|
191
191
|182|[How to programmatically trigger click event in reactjs?](#how-to-programmatically-trigger-click-event-in-reactjs)|
192
-
|183|[](#)|
193
-
|184|[](#)|
194
-
|185|[](#)|
195
-
|186|[](#)|
196
-
|187|[](#)|
197
-
|188|[](#)|
198
-
|189|[](#)|
192
+
|183|[Is it possible to use async/await in plain react?](#is-it-possible-to-use-async/await-in-plain-react)|
193
+
|184|[How to pass numbers to components?](#how-to-pass-numbers-to-components)|
194
+
|185|[What are styled components?](#what-are-styled-components)|
195
+
|186|[Give an example of styled components?](#give-an-example-of-styled-components)|
196
+
|187|[What is Relay?](#what-is-relay)|
197
+
|188|[How Relay is different from Redux?](#how-relay-is-different-from-redux)|
198
+
|189|[What are the common folder structures for react?](#what-are-the-common-folder-structures-for-react)|
199
199
|190|[](#)|
200
200
|191|[](#)|
201
201
|192|[](#)|
@@ -2731,4 +2731,88 @@ You could use the ref prop to acquire a reference to the underlying HTMLInputEle
2731
2731
```
2732
2732
this.inputElement.click();
2733
2733
```
2734
-
###
2734
+
### Is it possible to use async/await in plain react?
2735
+
React Native ships with Babel and some Babel presets, whereas React on the web is just React related code. f you want to use async/await on the web then either
Styled-components is a JavaScript library for styling React applications. It removes the mapping between styles and components, and lets you write actual CSS augmented with JavaScript.
2747
+
### Give an example of styled components?
2748
+
Lets create Title and Wrapper components with specific styles for each.
2749
+
```
2750
+
import React from 'react';
2751
+
import styled from 'styled-components';
2752
+
2753
+
// Create a <Title> react component that renders an <h1> which is centered, red and sized at 1.5em
2754
+
const Title = styled.h1`
2755
+
font-size: 1.5em;
2756
+
text-align: center;
2757
+
color: palevioletred;
2758
+
`;
2759
+
2760
+
// Create a <Wrapper> react component that renders a <section> with some padding and a papayawhip background
2761
+
const Wrapper = styled.section`
2762
+
padding: 4em;
2763
+
background: papayawhip;
2764
+
`;
2765
+
```
2766
+
These two variables, Title and Wrapper, are now a React components you can render like any other React component
2767
+
```
2768
+
<Wrapper>
2769
+
<Title>Lets start first styled component!</Title>
2770
+
</Wrapper>
2771
+
```
2772
+
### What is Relay?
2773
+
Relay is a JavaScript framework for providing a data layer and client-server communication to web applications using the React view layer.
2774
+
### How Relay is different from Redux?
2775
+
Relay is similar to redux in that they both use a single store. The main difference is that relay only manages state originated from the server, and all access to the state is used via GraphQL querys (for reading data) and mutations (for changing data). Relay caches the data for you and optimizes data fetching for you, by fetching only changed data and nothing more.
2776
+
### What are the common folder structures for react?
2777
+
Basically there are two common practices for reactjs file structure
2778
+
1.**Grouping by features or routes**
2779
+
One common way to structure projects is locate CSS, JS, and tests together inside folders grouped by feature or route.
2780
+
```
2781
+
common/
2782
+
Avatar.js
2783
+
Avatar.css
2784
+
APIUtils.js
2785
+
APIUtils.test.js
2786
+
feed/
2787
+
index.js
2788
+
Feed.js
2789
+
Feed.css
2790
+
FeedStory.js
2791
+
FeedStory.test.js
2792
+
FeedAPI.js
2793
+
profile/
2794
+
index.js
2795
+
Profile.js
2796
+
ProfileHeader.js
2797
+
ProfileHeader.css
2798
+
ProfileAPI.js
2799
+
```
2800
+
2.**Grouping by file type**
2801
+
Another popular way to structure projects is to group similar files together
0 commit comments