-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
910979a
commit 59c0ee6
Showing
10 changed files
with
174 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const API_URL : string = process.env.API_URL || "http://localhost:5000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createBrowserRouter } from "react-router-dom" | ||
import Homepage from "../pages/Homepage" | ||
|
||
const routes = [ | ||
{ | ||
path: "/", | ||
element: <Homepage />, | ||
}, | ||
] | ||
|
||
const routeBrowser = createBrowserRouter(routes) | ||
|
||
export default routeBrowser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useDispatch, useSelector } from "react-redux" | ||
import { exampleAction, exampleState } from "../redux/reducers/example" | ||
import { useEffect } from "react" | ||
|
||
const Hello =() =>{ | ||
const helloState = useSelector(exampleState) | ||
const dispatch = useDispatch() | ||
useEffect(() => { | ||
|
||
dispatch(exampleAction.setName({name:"React Boilerplate TS By Saddam"})) | ||
|
||
},[]) | ||
|
||
return( | ||
<div> | ||
<h1 className="text-red-500"> | ||
{helloState.name} | ||
</h1> | ||
</div> | ||
) | ||
} | ||
|
||
export default Hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import "./index.css"; | ||
import { RouterProvider } from "react-router-dom"; | ||
import routes from "./commons/routes"; | ||
import { Provider } from "react-redux"; | ||
import store from "./redux/store"; | ||
|
||
ReactDOM.createRoot(document.getElementById("root")!).render( | ||
<React.StrictMode> | ||
<div className="text-red-800"> | ||
<h1>Hello</h1> | ||
</div> | ||
<Provider store={store}> | ||
|
||
<RouterProvider router={routes} /> | ||
</Provider> | ||
|
||
</React.StrictMode>, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Hello from "../components/hello" | ||
|
||
const Homepage = () => { | ||
return ( | ||
<> | ||
<Hello /> | ||
</> | ||
) | ||
} | ||
|
||
export default Homepage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import axios from 'axios'; | ||
import { API_URL } from '../commons/constant'; | ||
|
||
export default axios.create({ | ||
baseURL: API_URL, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { PayloadAction, createSlice } from "@reduxjs/toolkit" | ||
import store from "../store" | ||
|
||
interface IExample{ | ||
name: string | ||
} | ||
|
||
const initialExample : IExample = { | ||
name: "" | ||
} | ||
|
||
const exampleSlicer = createSlice({ | ||
name: "example", | ||
initialState: initialExample, | ||
reducers:{ | ||
setName: (state: IExample, action : PayloadAction<IExample, string>)=>{ | ||
state.name = action.payload.name | ||
} | ||
} | ||
}) | ||
|
||
const exampleReducer = exampleSlicer.reducer | ||
export const exampleAction = exampleSlicer.actions | ||
|
||
export const exampleState = (state: store) => state.posts | ||
|
||
export default exampleReducer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { configureStore } from '@reduxjs/toolkit' | ||
import exampleReducer from './reducers/example' | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
posts: exampleReducer, | ||
}, | ||
}) | ||
|
||
export type store = ReturnType<typeof store.getState> | ||
export type AppDispatch = typeof store.dispatch | ||
|
||
|
||
export default store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters