Skip to content

Commit

Permalink
reorg tests for fiber and stack versions (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdustan authored Feb 17, 2017
1 parent 5f25a3b commit a2ba412
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ With that let’s get started! Our tour continues in [./src/mount.js](./src/moun
Please note this guide is a work in progress. Much of this knowledge is derived
from my experience in creating [React Hardware](https://github.com/iamdustan/react-hardware).

## Tests

* `npm test` will run the tests with the stack-based renderer
* `npm test -- --fiber` will run the tests with the upcoming fiber implementation

## Renderer Implementations

Expand Down
33 changes: 32 additions & 1 deletion src/fiber/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# It begins
# Tiny React Renderer

> Note that this is currently targeting the **React 16.0.0-alpha.2** release.
Creating a fiber-based React renderer is quite direct, though there are a few
awkward pieces around tooling that will be smoothed over in time.

Many languages have this concept of a `main`—the entry point to your
application. If you look at any React application code you’ve written you’ll see
that you “start” your app with a call like the following:

```jsx
// web
ReactDOM.render(React.createElement(MyApp), document.getElementById('app'));

// native
AppRegistry.registerComponent('MyApp', () => MyApp);
```

This is where your application enters into the React domain and comes alive. Your
root React element is instantiated and attached to the host environment.

With Fiber, all renderers begin (and maybe even end) in the React{Host}Fiber.js
file.

With that let’s get started. Our tour continues in
[./ReactTinyFiber.js](./ReactxTinyFiber.js)!

## Work in Progress

Please note this guide is a work in progress. Much of this knowledge is derived
from my experience in creating [React Hardware](https://github.com/iamdustan/react-hardware).

2 changes: 1 addition & 1 deletion index.js → src/stack/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const render = require('./src/mount');
const render = require('./mount');

module.exports = {render};

35 changes: 35 additions & 0 deletions src/stack/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "tiny-react-renderer-stack",
"private": true,
"description": "A tiny React stack renderer to demonstrate how to write a renderer.",
"main": "./index.js",
"scripts": {
"test": "node ./test"
},
"repository": {
"type": "git",
"url": "https://github.com/iamdustan/tiny-react-renderer"
},
"files": [
"*",
"package.json",
"README.md"
],
"keywords": [
"react",
"reactjs",
"renderer"
],
"author": "Dustan Kasten <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/iamdustan/tiny-render-renderer/issues"
},
"homepage": "https://github.com/iamdustan/tiny-render-renderer",
"dependencies": {
"fbjs": "^0.8.4",
"react": "15.3.x"
},
"devDependencies": {}
}

4 changes: 4 additions & 0 deletions src/stack/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


8 changes: 7 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

const assert = require('assert');
const React = require('react');
const TinyRenderer = require('./');
const args = process.argv.slice(2);

const TEST_FILE = args[0] === '-f' || args[0] === '--fiber'
? 'fiber'
: 'stack';

const TinyRenderer = require('./src/' + TEST_FILE);
const render = TinyRenderer.render;
const toJSON = (props) => {
if (props.children) {
Expand Down

0 comments on commit a2ba412

Please sign in to comment.