React-Redux with functional Components This is a pretty simple working example using React-Redux to select a user from app.com/user/:userId and then fetch/display that user's info from a remote API
Most of the examples/code I can find online use class-based components but since I already have part of a project written using a functional approach I'm looking for feedback on how I'm integrating redux into functional components. I'm also not a Javascript expert by any means either so general critique of my JS is welcome as well!
Store.js:
import { createStore } from &quot;redux&quot;;

const initialUser = { user: [] };

const userReducer = (state = initialUser, action) =&gt; {
  switch (action.type) {
    case &quot;ADD_USER&quot;:
      return Object.assign({}, state, { user: action.user });
    default:
      return state;
  }
};

export default function Store() {
  return createStore(userReducer);
}

Actions.js:
const validResp = (resp) =&gt; {
  return resp.data.code === 200;
};

const extractUser = (resp) =&gt; {
  return resp.data.data;
};

export const addUser = (resp) =&gt; {
  let user = &quot;&quot;;

  if (validResp(resp)) {
    user = extractUser(resp);
  }

  return {
    type: &quot;ADD_USER&quot;,
    user: user
  };
};

index.js:
import React from &quot;react&quot;;
import ReactDOM from &quot;react-dom&quot;;
import { Provider } from &quot;react-redux&quot;;
import { BrowserRouter as Router, Route } from &quot;react-router-dom&quot;;

import AppContainer from &quot;./AppContainer&quot;;
import Store from &quot;./Store&quot;;

const rootElement = document.getElementById(&quot;root&quot;);
ReactDOM.render(
  &lt;Provider store={Store()}&gt;
    &lt;Router&gt;
      &lt;Route path=&quot;/user/:userId&quot; component={AppContainer} /&gt;
    &lt;/Router&gt;
  &lt;/Provider&gt;,
  rootElement
);

AppContainer.js:
import React from &quot;react&quot;;
import { useEffect } from &quot;react&quot;;
import { useDispatch, useSelector } from &quot;react-redux&quot;;
import { useParams } from &quot;react-router-dom&quot;;
import axios from &quot;axios&quot;;

import { addUser } from &quot;./Actions&quot;;

const baseUrl = &quot;https://gorest.co.in/public-api/users/&quot;;

export default function AppContainer() {
  const url = baseUrl + useParams().userId;
  const user = useSelector((state) =&gt; state.user);
  const dispatch = useDispatch();

  useEffect(() =&gt; {
    axios.get(url).then((resp) =&gt; dispatch(addUser(resp)));
  });

  return &lt;App user={user} /&gt;;
}

function App(props) {
  return (
    &lt;div className=&quot;App&quot;&gt;
      Name: {props.user.name} &lt;br /&gt;
      id: {props.user.id}
    &lt;/div&gt;
  );
}
Concisely merging objects can be done with spread syntax instead of Object.assign. The ADD_USER case can use:
return { ...state, user: action.user };

Using spread syntax instead of Object.assign doesn't have a big impact here, but it makes things so much easier when the state structure grows to be large and complicated.
Functional programming does not reassign variables - everything should be declared with const. If you want to be more functional, change addUser to use the conditional operator to either assign the empty string or the extractUser result to the user variable:
export const addUser = (resp) =&gt; {
  const user = validResp(resp) ? extractUser(resp) : &quot;&quot;;
  return {
    type: &quot;ADD_USER&quot;,
    user
  };
};

(Note that if the key is named the same as the variable the value is in, you can use shorthand property names like above. You could also return the whole object at once without declaring a user variable first.)
useEffect bug Since you didn't provide a dependency array to useEffect, its callback will run on every render. I'm pretty sure this isn't desirable - you want it to run only on the initial render, right? Pass an empty dependency array to useEffect so that the callback inside only runs on mount:
useEffect(() =&gt; {
  axios.get(url).then((resp) =&gt; dispatch(addUser(resp)));
}, []);

Error handling If the axios.get Promise rejects, no indication is given. Always .catch Promises somewhere. You might want something like
useEffect(() =&gt; {
  axios.get(url)
    .then((resp) =&gt; dispatch(addUser(resp)))
    .catch((error) =&gt; dispatch(addError(error.message)));
}, []);

or something of the sort, to show that an error occurred.