Closed
Description
This is something @lacker was working on before Create React App. That project got shelved but I think we could revive it in some form now.
The idea is that instead of creating a project, you just start with a single file that is the root component:
App.js
import React from 'react';
export default function App() {
return <h1>Hello</h1>;
}
run-react-component App.js
It would use the same infrastructure as Create React App (exact same Babel and Webpack settings and CLI output), but would work in any folder without npm start
.
So you could run-react-component NavBar.js
and see just that component, regardless of where it is in the project, and whether it is in a project or not. The only run-react-component
requirement is that whatever you import
(e.g. react
) exists in node_modules
.
Benefits of this approach:
- Can jump right into prototyping with a single file. (Generate even less code? #642)
- The install cost is only paid once, you can run
run-react-component
right away in any folder on the disk. (The downside is you actually have to update global CLI to get updates.) - We could offer a way to “convert” such a prototype into a full CRA-based project, and they will be compatible.
- You could even use that in a CRA-based project to work on a single component at a time.
What do you think? Would that be useful?