Giter VIP home page Giter VIP logo

railgun's Introduction

React Hooks + TypeScript 开发 UI 组件库

Log

组件测试痛点:以 App 为入口,每次需写繁琐的测试页面代码

App.tsx

import React from 'react'
import { Routes, Route, Link } from 'react-router-dom'

import { ButtonTest } from './views/ButtonTest'
import { MenuTest } from './views/MenuTest'
import NotFound from './views/NotFound'

function App() {
    return (
        <div className="App">
            <div className="test-context">
                <Link to="/button">Button 测试</Link>
                <Link to="/menu">Menu 测试</Link>
            </div>

            <div className="test-view">
                <Routes>
                    <Route path="/" element={<ButtonTest />} />
                    <Route path="/button" element={<ButtonTest />} />
                    <Route path="/menu" element={<MenuTest />} />
                    <Route path="*" element={<NotFound />} />
                </Routes>
            </div>
        </div>
    )
}

export default App

index.tsx

import React from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'

import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/free-solid-svg-icons'

import './assets/styles/index.scss'
import App from './App'
import * as serviceWorker from './serviceWorker'

library.add(fas)

const root = createRoot(document.getElementById('root') as HTMLElement)

root.render(
    <React.StrictMode>
        {/* history model */}
        <BrowserRouter>
            <App />
        </BrowserRouter>
    </React.StrictMode>
)

serviceWorker.unregister()

解决办法:采用 Stroybook 方式管理,取消 App.tsx 入口

npx storybook@latest init

To run storybook you need to have node 16 or higher

railgun's People

Contributors

betacatpro avatar

Watchers

 avatar  avatar  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.