title: Explanation about Action Type
body: <p>I am following <a href="https://www.youtube.com/watch?v=93p3LxR9xfM&amp;t=2572s" rel="nofollow noreferrer">this video on youtube to learn redu</a>x </p>
  
  <p>Here the instructor created a reducer by doing something like this (we are calling it as a post reducer and it will merge with other reducer when we import it to rootreducer  </p>
  
  <pre><code>import { FETCH_POST, NEW_POST } from '../actions/type.js'
  
  
  const initialState = {
    items: [],
    item: {}
  }
  
  export default function(state = initialState, action) {
    switch (action.type) {
        default:
          return state
    }
  
  }
  </code></pre>
  
  <p>Above <code>import { FETCH_POST, NEW_POST } from '../actions/type.js'</code> are action types and contains only following things </p>
  
  <pre><code>export const FETCH_POST = 'FETCH_POST';
  export const NEW_POST = 'NEW_POST';
  </code></pre>
  
  <p>Now since this is related to redux, I understand what acton does but I don't get how do we get action here when we aren't importing anything and action does't seem to be defined. </p>
  
  <p>Maybe he would do it to fix this later but just to check if I am missing something?   </p>
  
  <p>Similarly, few minutes in the video (At around 42 minutes according to youtube video) ,He created a postAction folder where we have something like this </p>
  
  <pre><code>import { FETCH_POST, NEW_POST } from '.type.js'
  import axios from 'axios';
  
  
  export const fetchPosts = () =&gt; {
    return (dispatch) {
      axios.get("https://jsonplaceholder.typicode.com/posts").then(response =&gt; dispatch({
        type: FETCH_POST,
        payload: res
      })
  
  
    }
  
  } 
  </code></pre>
  
  <p>and without even importing anything, he extended the switch condition in above code like this </p>
  
  <pre><code>export default function(state = initialState, action) {
    switch (action.type) {
      case FETCH_POST:
        return {
          ...state,
          items: action.payload 
        }
        default:
          return state
    }
  </code></pre>
  
  <p>Similar to our first example, what is action here and how does it know about our action.type when we haven't imported anything? </p>