Skip to content

Commit 24f47fb

Browse files
enahsorDowen Robinsongaearon
authored
Removed deadlink from Event System section and added correct links (reactjs#3136)
* Removed deadlink from Event System section and added correct links * Changed wording of Event System section and removed react-native events link * Update codebase-overview.md Co-authored-by: Dowen Robinson <[email protected]> Co-authored-by: Dan Abramov <[email protected]>
1 parent 13ea21c commit 24f47fb

File tree

1 file changed

+4
-61
lines changed

1 file changed

+4
-61
lines changed

content/docs/codebase-overview.md

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,11 @@ For example, a test for [`setInnerHTML.js`](https://github.com/facebook/react/bl
3535

3636
### Warnings and Invariants {#warnings-and-invariants}
3737

38-
The React codebase uses the `warning` module to display warnings:
38+
The React codebase uses `console.error` to display warnings:
3939

4040
```js
41-
var warning = require('warning');
42-
43-
warning(
44-
2 + 2 === 4,
45-
'Math is not working today.'
46-
);
47-
```
48-
49-
**The warning is shown when the `warning` condition is `false`.**
50-
51-
One way to think about it is that the condition should reflect the normal situation rather than the exceptional one.
52-
53-
It is a good idea to avoid spamming the console with duplicate warnings:
54-
55-
```js
56-
var warning = require('warning');
57-
58-
var didWarnAboutMath = false;
59-
if (!didWarnAboutMath) {
60-
warning(
61-
2 + 2 === 4,
62-
'Math is not working today.'
63-
);
64-
didWarnAboutMath = true;
41+
if (__DEV__) {
42+
console.error('Something is wrong.');
6543
}
6644
```
6745

@@ -114,39 +92,6 @@ ReactRef.detachRefs = function(
11492
When possible, new code should use Flow annotations.
11593
You can run `yarn flow` locally to check your code with Flow.
11694

117-
### Dynamic Injection {#dynamic-injection}
118-
119-
React uses dynamic injection in some modules. While it is always explicit, it is still unfortunate because it hinders understanding of the code. The main reason it exists is because React originally only supported DOM as a target. React Native started as a React fork. We had to add dynamic injection to let React Native override some behaviors.
120-
121-
You may see modules declaring their dynamic dependencies like this:
122-
123-
```js
124-
// Dynamically injected
125-
var textComponentClass = null;
126-
127-
// Relies on dynamically injected value
128-
function createInstanceForText(text) {
129-
return new textComponentClass(text);
130-
}
131-
132-
var ReactHostComponent = {
133-
createInstanceForText,
134-
135-
// Provides an opportunity for dynamic injection
136-
injection: {
137-
injectTextComponentClass: function(componentClass) {
138-
textComponentClass = componentClass;
139-
},
140-
},
141-
};
142-
143-
module.exports = ReactHostComponent;
144-
```
145-
146-
The `injection` field is not handled specially in any way. But by convention, it means that this module wants to have some (presumably platform-specific) dependencies injected into it at runtime.
147-
148-
There are multiple injection points in the codebase. In the future, we intend to get rid of the dynamic injection mechanism and wire up all the pieces statically during the build.
149-
15095
### Multiple Packages {#multiple-packages}
15196

15297
React is a [monorepo](https://danluu.com/monorepo/). Its repository contains multiple separate packages so that their changes can be coordinated together, and issues live in one place.
@@ -211,9 +156,7 @@ Its source code is located in [`packages/react-reconciler`](https://github.com/f
211156

212157
### Event System {#event-system}
213158

214-
React implements a synthetic event system which is agnostic of the renderers and works both with React DOM and React Native. Its source code is located in [`packages/legacy-events`](https://github.com/facebook/react/tree/master/packages/legacy-events).
215-
216-
There is a [video with a deep code dive into it](https://www.youtube.com/watch?v=dRo_egw7tBc) (66 mins).
159+
React implements a layer over native events to smooth out cross-browser differences. Its source code is located in [`packages/react-dom/src/events`](https://github.com/facebook/react/tree/master/packages/react-dom/src/events).
217160

218161
### What Next? {#what-next}
219162

0 commit comments

Comments
 (0)