The joy of React+Redux with Elixir/OTP

The joy of React+Redux with Elixir/OTP  #ReactJS #Redux #Elixir

  • Graphically, this is the schema of a Redux app: – – Basically, Redux does the following: – – An OTP GenServer does the following: – – In short, we can use the same mental model for the client and server side.
  • We can dispatch events to Elixir, compute a new version state server side, propagate this state to redux, and our views will get updated automatically.
  • We have just implemented the thick red arrows: – – We will update the store with the state that comes from the server in two different situations.
  • With this, we have connected the server state with Redux state.
  • But, if you want to have state shared between different users, or we want to have pieces of the state in the server for other reasons, such as enforcing validation rules, we can use the same mental mode with Elixir GenServers.

Digital solutions partner. High quality work with Symfony, React and Elixir.
Continue reading “The joy of React+Redux with Elixir/OTP”

Why Redux is not so easy, some alternatives – Miron Machnicki – Medium

“Why Redux is not so easy, some alternatives” by @machnicki 

#Redux #ReactJS

  • State management with Redux is predictable but is not easy to learn and not fast to write.
  • There are a lot of benefits of using Relay with GraphQL.
  • Render() method of component is triggered only when data are observed and used in your component.
  • You have changed another part of store which is not used directly by your nested component.
  • You need to also remember, that data in your reducer should be normalized and would be better to have those data as flat as possible – check normalizr library.

The choice for a lot of programmers is quite obvious, but we should consider some cons of using Redux: You will need to care about functional principles and always return new value based on previous…
Continue reading “Why Redux is not so easy, some alternatives – Miron Machnicki – Medium”

Handling AJAX in your React Application with Agility

Handling #AJAX in your #React Application with #Agility  #reactjs #JavaScript #JStutorial

  • If the operation fails, it’s good practice to dispatch failure action, which in our case is LOAD_USER_FAILURE .
  • Redux-thunk allows an action creator to return a function instead of an action object.
  • When an action creator returns a function, that function will get executed by the Redux Thunk middleware.
  • Map the store’s state to component’s props.
  • Component { constructor() { super(); } componentDidMount() { this.props.getUserDetails(‘andela-rekemezie’); } render() { const { user } = this.props; return ( // Render user details ) } } // Store setup goes

There are different ways to handle AJAX with React. This tutorial will show you some ways to do it. Let’s get started.
Continue reading “Handling AJAX in your React Application with Agility”