Skip to main content

Posts

Showing posts from December, 2019

How to Pass Data from Child Component to Parent Component in React

How to Pass Data from One Component to Other Component in React? Props are used for passing data between the components. We usually use it to pass data from the parent component to the child component.  You should check out - What if we need to pass data from Parent to Child Component??? What if we need to pass data from Child to Parent Component??? If you are not using any state management library like Redux or React ContextAPI and you need to pass the data from child component to parent component. UseCase   - When clicking on any user rows, Implement functionality to get that user row data from the state data and display on page. Solution - Use Props as callback functions. Let’s see an Example, I have created two components one is – Parent Component as DisplyList.js and other one is – Child Component as UserListItem.js. Parent Component - DisplyList .js import   React   from   'react' import   ListItem   from ...

How to Pass Data from Parent Component to Child Component in React

How to Pass Data from One Component to Other Component in React? Props are used for passing data between the components. We usually use it to pass data from the parent component to the child component. Now, you can use props to pass data from parent to child component. You should check out -  What if we need to pass data from Child to Parent Component??? As an Example, I have created two components one is - ParentComponent.js and other is - ChildComponent.js .  Let’s see. ParentComponent.js - import   React   from   'react' import   ChildComponent   from   './ChildComponent' ; class   ParentComponent   extends   React . Component  {      render () {          return  (              < div >             ...

7 Reasons Why You Should Be Using React

How come React became so popular, and remains the hottest framework to work with? Each and every technology seems to have the same goal – easier, faster, and ultimately, better. Let’s see. 1.       Performance 2.       Speed & User Experience 3.       Backward Compatibility 4.       Development Speed 5.       Popularity 6.       Effective Testing 7.       Modularity Let see the below image for Popularity – React vs Angular – a Quick Comparison

Enable CORS in Nodejs | What Is CORS | How CORS Works

What Is CORS? CORS stands for Cross-origin resource sharing. Cross-origin resource sharing is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served. You only need to think about CORS when: 1.       API accessed by the browser 2.       API is hosted on a separate domain How CORS Works? CORS allows the server to explicitly whitelist certain origin and help to bypass the same-origin policy i.e. var   whitelist  = [ 'https://code-sample.com' ,  'https://codefari.com' ] If your server is configured for CORS, it will return an extra header with " Access-Control-Allow-Origin " on each response.   How to Enable CORS? For enabling CORS on your server application, you need two things. 1.       First, you need to determine the origins of whitelist 2.  ...