mirrorjs/mirror
mirrorjs/mirror has 1,427 GitHub stars and 103 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 05:33 UTC. Last push 2023-01-03.
A simple and powerful React framework with minimal API and zero boilerplate.
What you can do
- Minimal API(only 4 newly introduced)
- Actions done easy, sync or async
- Support code splitting
- Full-featured hook mechanism
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalMirror
A simple and powerful React framework with minimal API and zero boilerplate. (Inspired by dva and jumpstate)
Painless React and Redux.
Why?
We love React and Redux.
A typical React/Redux app looks like the following:
- An
actions/directory to manually create allaction types (oraction creators) - A
reducers/directory and tons ofswitchclause to capture allaction types - Apply middlewares to handle
async actions - Explicitly invoke
dispatchmethod to dispatch all actions - Manually create
historyto router and/or sync with store - Invoke methods in
historyor dispatch actions to programmatically changing routes
The problem? Too much boilerplates and a little bit tedious.
In fact, most part of the above steps could be simplified. Like, create actions and reducers in a single method, or dispatch both sync and async actions by simply invoking a function without extra middleware, or define routes without caring about history, etc.
That's exactly what Mirror does, encapsulates the tedious or repetitive work in very few APIs to offer a high level abstraction with efficiency and simplicity, and without breaking the pattern.
Features
- Minimal API(only 4 newly introduced)
- Easy to start
- Actions done easy, sync or async
- Support code splitting
- Full-featured hook mechanism
Getting Started
Creating an App
Use create-react-app to create an app:
$ npm i -g create-react-app
$ create-react-app my-app
After creating, install Mirror from npm:
$ cd my-app
$ npm i --save mirrorx
$ npm start
index.js
import React from 'react'
import mirror, {actions, connect, render} from 'mirrorx'
// declare Redux state, reducers and actions,
// all actions will be added to `actions`.
mirror.model({
name: 'app',
initialState: 0,
reducers: {
increment(state) { return state + 1 },
decrement(state) { return state - 1 }
},
effects: {
async incrementAsync() {
await new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, 1000)
})
actions.app.increment()
}
}
})
// connect state with component
const App = connect(state => {
return {count: state.app}
})(props => (
<div>
<h1>{props.count}</h1>
{/* dispatch the actions */}
<button onClick={() => actions.app.decrement()}>-</button>
<button onClick={() => actions.app.increment()}>+</button>
{/* dispatch the async action */}
<button onClick={() => actions.app.incrementAsync()}>+ Async</button>
</div>
)
)
// start the app,`render` is an enhanced `ReactDOM.render`
render(<App />, document.getElementById('root'))
Demo
Guide
See Guide.
API
See API Reference.
Examples
- User-Dashboard (An example similar to dva-user-dashboard)
- Counter
- Simple-Router
- Todo
Change log
See CHANGES.md.
FAQ
Does Mirror support TypeScript?
Yes, it does.
Does Mirror support Redux DevTools Extension?
Yes, Mirror integrates Redux DevTools by default to make your debugging more easily.
Can I use extra Redux middlewares?
Yes, specify them in mirror.defaults is all you need to do, learn more from the Docs.
I'm really into Redux-Saga, is there any way to use it in Mirror?
Yes of course, take a look at the addEffect option.
Which version of react-router does Mirror use?
react-router v4.
Explore related projects
freeCodeCamp/freeCodeCamp
freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.
458,753 starsdonnemartin/system-design-primer
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
377,329 starsreact/react
The library for web and native user interfaces.
252,409 starsvuejs/vue
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
212,631 stars