huwcarwyn / react-laravel-boilerplate

A Laravel REST API backend with React/Redux, hot module reloading in development and route-level code splitting
MIT License
172 stars 42 forks source link

React Boilerplate? #28

Closed ThinkDevStudios closed 5 years ago

ThinkDevStudios commented 5 years ago

Hi huwcarwyn. Just wondering if your using a specific react boilerplate or a custom one for this project. Trying to understand more how the react directories in this project works.

huwcarwyn commented 5 years ago

I made all this myself - post a couple questions and I'll do my best to answer :)

ThinkDevStudios commented 5 years ago

Im trying to understand the store directory. The action-creators, reducers, and selectors. The use of entities within the reducers directory. Lets say if i were to create a customers api. Where should i declare the api? Axios in the action creator session folder? And?

huwcarwyn commented 5 years ago

Action creators: This is where I usually make the API requests, then I dispatch some action afterwards to update the store with the result. You can choose to either handle errors with the request here, or wherever you call the action creators.

Reducers: Simple redux reducers, nothing special here. I have made entities reducers so that I can keep related reducers that act on the same part of the state together.

Selectors: These are basically functions that get things from the state. I have a selector to get the current user for example since I need to do that lots.

I have an example of setting up a new part of the state here, you could replace Post with Customer in your case https://github.com/huwcarwyn/react-laravel-boilerplate/pull/26/files

ThinkDevStudios commented 5 years ago

Thank you. This is an amazing boilerplate. This makes the development feel like a breeze.

huwcarwyn commented 5 years ago

Thank you very much for the kind words :) I uploaded it only as a personal thing but I'm glad others like it too!