1.0.17 • Published 4 years ago

c-router v1.0.17

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

c-router

custom react router-accepts layouts and components

NPM JavaScript Style Guide

Install

npm install --save c-router

Usage

// App.js
import React, { Component } from "react";
import CRouter from "c-router";
import { appRoutes } from "./Routes";
class App extends Component {
  render() {
    return <CRouter routes={appRoutes} />;
  }
}
ReactDOM.render(<App />, document.getElementById("root"));

// Routes.js
import { Home, AboutUs } from "./pages";
import { DefaultLayout, EmptyLayout } from "../layouts";

export const appRoutes = [
  {
    exact: true,
    comp: Home,
    path: "/",
    layout: DefaultLayout
  },
  {
    exact: false,
    comp: AboutUs,
    path: "/AboutUs",
    layout: EmptyLayout
  }
];

//Layouts

// EmptyLayout.js
import React from "react";
import AppBar from "./AppBar";

export default function EmptyLayout({ children }) {
  return (
    <div>
      {/* our content goes in here */}
      {children}
    </div>
  );
}

// DefaultLayout
import React from "react";

export default function DefaultLayout({ children }) {
  return (
    <div>
      <AppBar />
      {children}
    </div>
  );
}

// pages/Views

// Home.js

import React from "react";

export default function HomePage() {
  return (
    <div>
      <p>Welcome to CRoute HomePage</p>
    </div>
  );
}
// AboutUs.js

import React from "react";
export default function AboutUs() {
  return (
    <div>
      <p>About us page</p>
    </div>
  );
}

License

MIT © homericks

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago