-
-
Notifications
You must be signed in to change notification settings - Fork 4
Feat: Atomic Render Nodes #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
change of plan, we're building a Mutable DOM for base set of nodes for ReactNative first |
This is now valid code import {Document, render} from './src/lib/dom';
function App() {
const document = new Document();
const textElm = document.createElement('Text');
let count = 0;
const text = document.createTextNode(count);
const safeAreaView = document.createElement('SafeAreaView');
textElm.appendChild(text);
setInterval(() => {
text.data = ++count;
}, 1000);
safeAreaView.appendChild(textElm);
const tree = render(safeAreaView);
return tree;
}
export default App; |
also standardises how to work with the bridge and dom nodes still need to add compat with web DOM to support maximum frameworks
256eb1e
to
67b577e
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 4bbae96:
|
add handlers for prop updation this includes updates to the style props and proxies the event addition to props for press functionality. the commit also adds all the remaining non-deprecated components to the registry
Close to a full DOM
Example of the above changes import {Document, render} from './src/lib/dom';
const document = new Document();
function App() {
let count = 0;
const safeAreaView = document.createElement('SafeAreaView');
const countTextNode = document.createTextNode(count);
const countText = document.createElement('Text');
countText.appendChild(countTextNode);
// set the isHighlighted prop on the react native host component Text
countText.setAttribute('isHighlighted', true);
safeAreaView.style.marginTop = 100;
Object.assign(countText.style, {
fontSize: 52,
textAlign: 'center',
});
const buttonNode = createButton();
buttonNode.addEventListener('onPress', () => {
const childText = buttonNode.children[0];
const buttonTNode = childText.children[0];
countTextNode.data = ++count;
const isEven = count % 2 === 0;
buttonTNode.data = isEven ? 'Even' : 'Odd';
Object.assign(childText.style, {
color: count % 2 === 0 ? 'green' : 'red',
});
});
safeAreaView.appendChild(countText);
safeAreaView.appendChild(buttonNode);
let tree = render(safeAreaView);
return tree;
}
function createButton() {
const touchable = document.createElement('TouchableOpacity');
const text = document.createElement('Text');
const textNode = document.createTextNode('Press Me');
Object.assign(touchable.style, {
alignItems: 'center',
justifyContent: 'center',
borderRadius: 6,
margin: 12,
});
Object.assign(text.style, {
color: 'black',
fontSize: 45,
});
text.appendChild(textNode);
touchable.appendChild(text);
return touchable;
}
export default App; |
split the dom implementation into their own modules
also changes the package structure
in case we plan to publish it later on
and update queue for removal of children
Checkpoint: Merging. |
An attempt at getting rid of the dependency on React for building the tree