Skip to content

Commit e9ae4f1

Browse files
initial
0 parents  commit e9ae4f1

20 files changed

+6416
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
dist/
3+
node_modules/
4+
.snapshots/
5+
*.min.js

.eslintrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"prettier",
5+
"plugin:prettier/recommended",
6+
"eslint:recommended",
7+
"plugin:react/recommended",
8+
"plugin:@typescript-eslint/eslint-recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"plugins": ["@typescript-eslint", "prettier", "react", "react-hooks"],
13+
"rules": {
14+
"react-hooks/rules-of-hooks": "error",
15+
"no-debugger": "off",
16+
"no-useless-escape": "off",
17+
"react-hooks/exhaustive-deps": "warn",
18+
"@typescript-eslint/no-non-null-assertion": "off",
19+
"@typescript-eslint/ban-ts-comment": "off",
20+
"@typescript-eslint/no-explicit-any": "off"
21+
},
22+
"settings": {
23+
"react": {
24+
"version": "detect"
25+
}
26+
},
27+
"env": {
28+
"browser": true,
29+
"node": true
30+
},
31+
"globals": {
32+
"JSX": true
33+
}
34+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
yarn-error.logs

.prettierrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"bracketSpacing": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"tabWidth": 2,
6+
"semi": false,
7+
"printWidth": 120,
8+
"jsxSingleQuote": true,
9+
"endOfLine": "auto"
10+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# React Router Filebased
2+
3+
Copyright (c) 2023 Mohamed Hussien
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# react-router-filebased
2+
3+
## About React-Router-Filebased
4+
5+
React-Router-Filebased is a lightweight npm package designed to simplify your React application's routing process. This package is built on top of the popular React Router Dom v6 library and includes file-based routing with lazy loading capabilities, making it easier to manage your application's routes.
6+
7+
With React-Router-Filebased, you can create routes directly from your file structure. This means you can organize your components and routes in a logical way that makes sense for your application. In addition, the package supports lazy loading, so your components and routes will only be loaded when they are needed, reducing the initial load time of your application.
8+
9+
## Install
10+
11+
```bash
12+
cd project-name
13+
npm install --save react-router-filebased
14+
mkdir src/pages
15+
```
16+
17+
## Usage
18+
19+
```tsx
20+
// src/App.tsx
21+
import React from 'react'
22+
import FileBasedProvider from 'react-router-filebased'
23+
24+
function App() {
25+
return <FileBasedProvider />
26+
}
27+
export default App
28+
```
29+
30+
```tsx
31+
// src/pages/index.tsx
32+
import React from 'react'
33+
34+
function Home() {
35+
return <h1>Home Page</h1>
36+
}
37+
export default Home
38+
```
39+
40+
```tsx
41+
// src/pages/[id].tsx
42+
import React from 'react'
43+
import { useParams } from 'react-router-dom'
44+
45+
function DynamicRoute() {
46+
const { id } = useParams()
47+
return <h1>DynamicRoute with id : {id}</h1>
48+
}
49+
export default DynamicRoute
50+
```
51+
52+
```tsx
53+
// src/pages/layout.tsx
54+
import React, { ReactNode } from 'react'
55+
56+
type Props = {
57+
children: ReactNode
58+
}
59+
function RootLayout({ children }: Props) {
60+
return <div>{children}</div>
61+
}
62+
export default RootLayout
63+
```
64+
65+
## License
66+
67+
MIT © [dev-mohamed-hussien](https://github.com/dev-mohamed-hussien)

jestconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"transform": {
3+
"^.+\\.(t|j)sx?$": "ts-jest"
4+
},
5+
"testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
6+
"moduleFileExtensions": [
7+
"ts",
8+
"tsx",
9+
"js",
10+
"jsx",
11+
"json",
12+
"node"
13+
],
14+
"testEnvironment": "jsdom"
15+
}

package-lock.json

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)