<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SM Toufiqul Hoque</title>
    <description>The latest articles on DEV Community by SM Toufiqul Hoque (@toufiqulhoque).</description>
    <link>https://dev.to/toufiqulhoque</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F779090%2Fb2396495-9289-4316-93d8-860ffe43cc55.jpeg</url>
      <title>DEV Community: SM Toufiqul Hoque</title>
      <link>https://dev.to/toufiqulhoque</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toufiqulhoque"/>
    <language>en</language>
    <item>
      <title>Drop down filtering with react</title>
      <dc:creator>SM Toufiqul Hoque</dc:creator>
      <pubDate>Sat, 26 Feb 2022 10:55:18 +0000</pubDate>
      <link>https://dev.to/toufiqulhoque/drop-down-filtering-with-react-9ml</link>
      <guid>https://dev.to/toufiqulhoque/drop-down-filtering-with-react-9ml</guid>
      <description>&lt;p&gt;Our goal is to change our data dynamically using Drop down filtering here is the code ...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';
import mockData from '../mockData.json';


const Dropdown = () =&amp;gt; {
  const [items, setItems] = useState(mockData);

   const filterItem=(gen)=&amp;gt;{
     const updatedItem=mockData.filter((curElem)=&amp;gt;{
       return curElem.gender===gen
     });
     setItems(updatedItem)

   }
  return (
    &amp;lt;div&amp;gt;

        &amp;lt;select onChange={(e) =&amp;gt; filterItem(e.target.value)}  &amp;gt; 
          &amp;lt;option &amp;gt;Female&amp;lt;/option&amp;gt;
          &amp;lt;option&amp;gt;Male&amp;lt;/option&amp;gt;

        &amp;lt;/select&amp;gt;


        {items.map(val =&amp;gt; (
          &amp;lt;div key={val.id} style={{ margin: '30px' }}&amp;gt;
            &amp;lt;div&amp;gt;{`Band: ${val.first_name}`}&amp;lt;/div&amp;gt;
            &amp;lt;div&amp;gt;{`Albums: ${val.last_name}`}&amp;lt;/div&amp;gt;
            &amp;lt;div&amp;gt;{`Members: ${val.email}`}&amp;lt;/div&amp;gt;
            &amp;lt;div&amp;gt;{`Members: ${val.gender}`}&amp;lt;/div&amp;gt;

          &amp;lt;/div&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
  );
}

export default Dropdown;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Redux Toolkit Quick Start</title>
      <dc:creator>SM Toufiqul Hoque</dc:creator>
      <pubDate>Fri, 25 Feb 2022 06:08:17 +0000</pubDate>
      <link>https://dev.to/toufiqulhoque/redux-toolkit-quick-start-1f49</link>
      <guid>https://dev.to/toufiqulhoque/redux-toolkit-quick-start-1f49</guid>
      <description>&lt;h2&gt;
  
  
  Redux
&lt;/h2&gt;

&lt;p&gt;It was first introduced to the front-end world in 2015 by Dan Abramov and Andrew Clark as a revolutionary state management library. It is now one of the most popular state management libraries on the web.&lt;br&gt;
Redux is a front-end component state management system, which makes managing multiple component states easier for complex apps. React, Angular, or Vue provide components that internally manage their own states.&lt;/p&gt;
&lt;h2&gt;
  
  
  Redux Toolkit
&lt;/h2&gt;

&lt;p&gt;I have used the Redux toolkit in my projects. Because it is easy to use and It is also easily maintainable and scalable . Also, there are many other benefits such as efficient testing, easy debugging and better performance that Redux brings to the table.&lt;/p&gt;
&lt;h2&gt;
  
  
  Redux Toolkit Installation
&lt;/h2&gt;
&lt;h2&gt;
  
  
  Step 1: install packages
&lt;/h2&gt;

&lt;p&gt;Create a React Redux App&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app --template redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the Redux Toolkit and React-Redux packages to your existing project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @reduxjs/toolkit react-redux
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create a Redux Store​
&lt;/h2&gt;

&lt;p&gt;Create a file named src/redux/store.js. Import the configureStore API from Redux Toolkit. We'll start by creating an empty Redux store, and exporting it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { configureStore } from '@reduxjs/toolkit'

export const store = configureStore({
  reducer: {},
})


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Provide the Redux Store to React
&lt;/h2&gt;

&lt;p&gt;Once the store is created, we can make it available to our React components by putting a React-Redux  around our application in src/index.js. Import the Redux store we just created, put a  around your , and pass the store as a prop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import { store } from './app/store'
import { Provider } from 'react-redux'

ReactDOM.render(
  &amp;lt;Provider store={store}&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/Provider&amp;gt;,
  document.getElementById('root')
)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Create a Redux State Slice
&lt;/h2&gt;

&lt;p&gt;Create a file named src/redux/slices/foodSlice.js.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createSlice } from '@reduxjs/toolkit'

const initialState = {
  value: 0,
}

export const counterSlice = createSlice({
  name: 'counter',
  initialState,
  reducers: {
    increment: (state) =&amp;gt; {
      // Redux Toolkit allows us to write "mutating" logic in reducers. It
      // doesn't actually mutate the state because it uses the Immer library,
      // which detects changes to a "draft state" and produces a brand new
      // immutable state based off those changes
      state.value += 1
    },
    decrement: (state) =&amp;gt; {
      state.value -= 1
    },
    incrementByAmount: (state, action) =&amp;gt; {
      state.value += action.payload
    },
  },
})

// Action creators are generated for each case reducer function
export const { increment, decrement, incrementByAmount } = counterSlice.actions

export default counterSlice.reducer

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Add Slice Reducers to the Store
&lt;/h2&gt;

&lt;p&gt;On the src/redux/store.js path add Slice reducers to the store&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { configureStore } from '@reduxjs/toolkit'
import counterReducer from '../features/counter/counterSlice'

export const store = configureStore({
  reducer: {
    counter: counterReducer,
  },
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>CRUD Operation</title>
      <dc:creator>SM Toufiqul Hoque</dc:creator>
      <pubDate>Thu, 23 Dec 2021 17:02:32 +0000</pubDate>
      <link>https://dev.to/toufiqulhoque/crud-operation-1jp4</link>
      <guid>https://dev.to/toufiqulhoque/crud-operation-1jp4</guid>
      <description>&lt;p&gt;CRUD Operation&lt;/p&gt;

&lt;p&gt;Working with CRUD operations we have to work with a database. CRUD operations are often used with SQL and also No SQL, a topic we've covered in depth. Since SQL is so prevalent in the development community, people should understand how CRUD operations work.&lt;/p&gt;

&lt;p&gt;Definition of CRUD&lt;/p&gt;

&lt;p&gt;The acronym CRUD refers to the four basic functions of persistent storage, including create, read, update, and delete. Also, each letter in the acronym can refer to all functions executed in relational database applications and mapped to a standard HTML method, SQL statement and NoSQL statement or DDS operation&lt;/p&gt;

&lt;p&gt;Explaining CRUD Operations&lt;/p&gt;

&lt;p&gt;When we need to keep the track of customer data,account, payment information, health&lt;br&gt;
Data, and other records require data storage hardware and applications that provide persistent storage.There are many types of databases: hierarchical databases, graph databases, and object-oriented databases to name a few. The most commonly implemented type of database is a relational database, which consists of data tabled in rows and columns and connected to other tables with complementary information by a system of keywords that includes primary keys and foreign keys.And we use another database which is NoSQL database.&lt;/p&gt;

&lt;p&gt;Four CRUD Operations Components Explained (NoSQL)&lt;/p&gt;

&lt;p&gt;There are four CRUD operation components :&lt;/p&gt;

&lt;p&gt;Create Operations&lt;/p&gt;

&lt;p&gt;Read Operations&lt;/p&gt;

&lt;p&gt;Update Operations&lt;/p&gt;

&lt;p&gt;Delete Operations&lt;/p&gt;

&lt;p&gt;Create Operations&lt;br&gt;
Add new documents to a collection. If the collection does not exist, insert operations will create the collection.&lt;br&gt;
MongoDB provides the following methods to insert documents into a collection:&lt;br&gt;
db.collection.insertOne() New in version 3.2&lt;br&gt;
db.collection.insertMany() New in version 3.2&lt;br&gt;
In MongoDB, insert operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.&lt;/p&gt;

&lt;p&gt;Read Operations&lt;br&gt;
Read Operation read the documents from a collection:&lt;/p&gt;

&lt;p&gt;In MongoDB, insert operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.&lt;br&gt;
Update Operations&lt;br&gt;
In MongoDB, insert operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.&lt;br&gt;
In MongoDB, insert operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.&lt;/p&gt;

&lt;p&gt;db.collection.updateOne() New in version 3.2&lt;br&gt;
db.collection.updateMany() New in version 3.2&lt;br&gt;
db.collection.replaceOne() New in version 3.2&lt;/p&gt;

&lt;p&gt;You can specify criteria, or filters, that identify the documents to update. These filters use the same syntax as read operations.&lt;/p&gt;

&lt;p&gt;Delete Operations&lt;br&gt;
Delete operations remove documents from a collection. MongoDB provides the following methods to delete documents of a collection:&lt;br&gt;
db.collection.deleteOne() New in version 3.2&lt;br&gt;
db.collection.deleteMany() New in version 3.2&lt;br&gt;
In MongoDB, insert operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.&lt;br&gt;
You can specify criteria, or filters, that identify the documents to remove. These filters use the same syntax as read operations.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>State-Props</title>
      <dc:creator>SM Toufiqul Hoque</dc:creator>
      <pubDate>Wed, 22 Dec 2021 17:44:36 +0000</pubDate>
      <link>https://dev.to/toufiqulhoque/state-props-mih</link>
      <guid>https://dev.to/toufiqulhoque/state-props-mih</guid>
      <description>&lt;p&gt;State&lt;/p&gt;

&lt;p&gt;States are allowed to create and manage their own data. So unlike props , state can not pass data  with state, but they can create and manage it internally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Test extends React.Component {    
    constructor() {    
        this.state = {          
            name: "Toufiq"    
        };  
    }    
    render() {    
        return (      
            &amp;lt;div&amp;gt;             
              &amp;lt;p&amp;gt;{this.state.name}&amp;lt;/p&amp;gt;      
            &amp;lt;/div&amp;gt;    
        );  
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is nothing useful going on in this case, but imagine doing something different based on the prop value, maybe setting a state value would be better.&lt;/p&gt;

&lt;p&gt;A child component should never change its properties, so if something changes a variable, it should belong to the component state.&lt;/p&gt;

&lt;p&gt;Child components can also use props to gain access to methods in the parent component. This is a good way to centralize management of state in the parent component and avoid children from having to manage their own state.&lt;/p&gt;

&lt;p&gt;State should not be modified directly, but it can be modified with a special method called setState( ).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.state.id = “hello”; // wrong

this.setState({         // correct  
    id: "hello"
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Props&lt;br&gt;
Props used to pass data between React components. React data flow between component is unidirectional(from parent components to child components)&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class pComponent extends Component {    
    render() {    
        return (        
            &amp;lt;cComponent name="First Child" /&amp;gt;    
        );  
    }
}

const cComponent = (props) =&amp;gt; {    
    return &amp;lt;p&amp;gt;{props.name}&amp;lt;/p&amp;gt;; 
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
