Skip to main content

Posts

Showing posts with the label add meta tag in react

React getDerivedStateFromProps Method | Components Lifecycle

The getDerivedStateFromProps Method  - The getDerivedStateFromProps() method is called first when a component gets updated. This is still the natural place to set the  state  object based on the initial  props . Explore to Understand   -  React Lifecycle Components After changes the color to blue, but since the getDerivedStateFromProps() method is called, which updates the state with the color from the color attribute, the color is still rendered as yellow.  See the below example , class   Header   extends   React . Component  {      constructor ( props ) {        super ( props );        this . state  = { color:   "red" };     }      static   getDerivedStateFromProps ( props ,  state ) {        return  { col...

Getting substring of props value – React

The below example will helps to getting substring of props value using React and it will also very helpful to maximum amount of characters in a div/paragraph tag in React . As an Example, import   React , {  Component  }  from   'react' export   default   class   UserDetail   extends   Component  {      state  ={          min_char:   0 ,          max_char: 150 ,          desciption: ''     }      constructor ( props ) {          super ( props );                   let   desc  =  this . props . desciption ;          this . state . d...

Add/Update Meta Tags in React | Dynamic Meta Tags

What Is Metadata?   The Metadata is data (information) about data and the Meta tag provides metadata about the HTML document. The Metadata will not be displayed on the page, but will be machine parsable. The Meta elements are typically used to specify the following points: 1.       The page description, 2.       The page keywords, 3.       The page author of the document 4.       The page last modified 5.       The page viewport 6.       The page other metadata Notes - The <meta> tags always inside the <head> element and meta tags always passed as name/value pairs. As An Example in HTML, < head >      < meta   charset = "UTF-8" >      < meta   name = "description"   content = "Free Web tutorials" > ...