GithubHelp home page GithubHelp logo

react-template's Introduction

usage

add to your own repository

git clone xxx
rm -rf .git // remove this git remote
git init
git remote add origin xxx // add new origin what is empty repository
git add .
git commit -m "init"
git push -u master

start project

npm i
npm start

push your code to repository

npm run commit [some message]

publish your code to build dir and commit to repositroy

npm run publish [some message]

logs

#19-02-15 init with antd & ts

use browser router & it can use file's dir path to site path; root path from ./src/page

file dir to path

./

./src

./src/page

./src/page/index.tsx

./src/page/404.tsx

./src/page/test

./src/page/test/index.tsx

page dir is ./src/page

indexPage :localhost:3000=>./src/page/index.tsx

test:localhost:3000/test=>./src/page/test/index.tsx

if there has 404.tsx, the 404.tsx will redirect to ./src/page/404.tsx

the page data store control is at ./src/models the model's content is :

export default{
  state:{
    test:'ccc'
  },
  reducers:{},
  effects:{},
}

file's name will be store's name

import React from 'react';
import { connectModel } from '../util';

@connectModel(
    (state: any) => ({
        indexData: state.index
    }),
    (dispatch: any) => ({

    })
)
export default class App extends React.Component<any, any>{
    render() {
        console.log(this.props);
        return (
            <div>
               index
            </div>
        );
    }
}

so the props:

{
  // some attr
  indexData:{
    test:'ccc'
  }
}

20190225 update

if you want to use hash Router , just replace

import { Switch, Route, BrowserRouter as Router } from "react-router-dom";

to

import { Switch, Route, HashRouter as Router } from "react-router-dom";

then you can use HashRouter to adapt to gitpage or giteepage,when use spa.

also when using Link at HashRouter will report an error,but it dose not matter.so just do it!

20190227 update

if you want to declare module or some unknown type , you can create a file named ./src/types.d.ts to resolve it

test

react-template's People

Contributors

kinghoo5201 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.