Giter Site home page Giter Site logo

react-news's Introduction

Ant Design And Typescript

a template for react, just play ~

2020Hooks重构版

启动流程

React News

组织结构

    
    components      组件
    core            核心
    layout          布局
    pages           业务页面
    routes          主路由页面
    shared          共享服务
    store           全局redux
    styles          样式
    utils           工具

预览

Rocket Redis

注意类型声明

// Hooks FC

import React, { useEffect, useState } from 'react'

const MyHooks = () => {
  const [count, setCount] = useState(0)

  useEffect(() => {
    document.title = `You clicked ${count} times`
  }, [count]) // 仅在 count 更改时更新

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>Click me</button>
    </div>
  )
}
export default MyHooks


// class component
export interface AdminRouteProps {
  routes: RouteConfig[]
}

export interface AdminRouteState {
  collapsed: boolean
}

class AdminRoute extends React.Component<AdminRouteProps, AdminRouteState> {
  state = {
    collapsed: false
  }
  toggle = () => {
    this.setState({
      collapsed: !this.state.collapsed
    })
  }

  render() {
    return (
      <Layout className="ant-pro-basicLayout">
        <AppSide collapsed={this.state.collapsed} />
        <Layout>
          <AppHeader collapsed={this.state.collapsed} toggle={this.toggle} />
          <Content className="site-layout-background">
            <div className="ant-pro-basicLayout-content">
              <GroupRoute routes={this.props.routes} />
            </div>
          </Content>
        </Layout>
      </Layout>
    )
  }
}

export default AdminRoute

Scripts

yarn start

use .env.local file to config dev options Open http://localhost:3000 to view it in the browser.

yarn format and yarn lint

format and lint fix code

yarn test

Launches the test runner in the interactive watch mode.

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

react-news's People

Contributors

guobin211 avatar

Stargazers

Donie avatar  avatar

Watchers

James Cloos avatar liuh 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.