Skip to content

Commit

Permalink
fix eslint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
saddam-satria committed Jan 17, 2024
1 parent 59c0ee6 commit d731459
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ module.exports = {
'no-underscore-dangle': 'off',
'default-param-last': 'off',
radix: 'off',
"import/extensions" :"off",
"import/no-unresolved": "off",
"react/react-in-jsx-scope": "off",
"no-param-reassign": "off",
"react-hooks/exhaustive-deps": "warn"
},
settings: {
react: {
Expand Down
2 changes: 1 addition & 1 deletion src/commons/constant.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const API_URL : string = process.env.API_URL || "http://localhost:5000"
export const API_URL: string = process.env.API_URL || "http://localhost:5000";
16 changes: 8 additions & 8 deletions src/commons/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { createBrowserRouter } from "react-router-dom"
import Homepage from "../pages/Homepage"
import { createBrowserRouter } from "react-router-dom";
import Homepage from "../pages/Homepage";

const routes = [
{
path: "/",
element: <Homepage />,
},
]
path: "/",
element: <Homepage />,
},
];

const routeBrowser = createBrowserRouter(routes)
const routeBrowser = createBrowserRouter(routes);

export default routeBrowser
export default routeBrowser;
36 changes: 16 additions & 20 deletions src/components/hello.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { useDispatch, useSelector } from "react-redux"
import { exampleAction, exampleState } from "../redux/reducers/example"
import { useEffect } from "react"
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { exampleAction, exampleState } from "../redux/reducers/example";

const Hello =() =>{
const helloState = useSelector(exampleState)
const dispatch = useDispatch()
useEffect(() => {
const Hello = () => {
const helloState = useSelector(exampleState);
const dispatch = useDispatch();
useEffect(() => {
dispatch(exampleAction.setName({ name: "React Boilerplate TS By Saddam" }));
}, []);

dispatch(exampleAction.setName({name:"React Boilerplate TS By Saddam"}))
return (
<div>
<h1 className="text-red-500">{helloState.name}</h1>
</div>
);
};

},[])

return(
<div>
<h1 className="text-red-500">
{helloState.name}
</h1>
</div>
)
}

export default Hello
export default Hello;
6 changes: 2 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import { Provider } from "react-redux";
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>
<Provider store={store}>

<RouterProvider router={routes} />
<RouterProvider router={routes} />
</Provider>

</React.StrictMode>,
);
14 changes: 6 additions & 8 deletions src/pages/Homepage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import Hello from "../components/hello"
import Hello from "../components/hello";

const Homepage = () => {
return (
<>
<Hello />
</>
)
}
return (
<Hello />
);
};

export default Homepage
export default Homepage;
6 changes: 3 additions & 3 deletions src/pkg/axios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import { API_URL } from '../commons/constant';
import axios from "axios";
import { API_URL } from "../commons/constant";

export default axios.create({
baseURL: API_URL,
});
});
38 changes: 19 additions & 19 deletions src/redux/reducers/example.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { PayloadAction, createSlice } from "@reduxjs/toolkit"
import store from "../store"
import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import store from "../store";

interface IExample{
name: string
interface IExample {
name: string;
}

const initialExample : IExample = {
name: ""
}
const initialExample: IExample = {
name: "",
};

const exampleSlicer = createSlice({
name: "example",
initialState: initialExample,
reducers:{
setName: (state: IExample, action : PayloadAction<IExample, string>)=>{
state.name = action.payload.name
}
}
})
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
const exampleReducer = exampleSlicer.reducer;
export const exampleAction = exampleSlicer.actions;

export const exampleState = (state: store) => state.posts
export const exampleState = (state: store) => state.posts;

export default exampleReducer
export default exampleReducer;
13 changes: 6 additions & 7 deletions src/redux/store.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { configureStore } from '@reduxjs/toolkit'
import exampleReducer from './reducers/example'
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 type store = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;


export default store
export default store;

0 comments on commit d731459

Please sign in to comment.