Skip to content

Commit

Permalink
Fixing multiple screen usage
Browse files Browse the repository at this point in the history
Passing the screen reference when instantiating blessed nodes to avoid issues related to multiple screens
  • Loading branch information
Yomguithereal committed Jun 26, 2019
1 parent 317182c commit dd9a920
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fiber/fiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const createBlessedRenderer = function(blessed) {
screen: typeof blessed.Screen,
};

let screenRef = null;

const BlessedReconciler = ReactFiberReconciler({
supportsMutation: true,
supportsPersistence: false,
Expand Down Expand Up @@ -46,7 +48,7 @@ const createBlessedRenderer = function(blessed) {
if (type.startsWith(blessedTypePrefix)) {
type = type.slice(blessedTypePrefix.length);
}
const instance = blessed[type](appliedProps);
const instance = blessed[type]({...appliedProps, screen: screenRef});
instance.props = props;
instance._eventListener = (...args) => eventListener(instance, ...args);
instance.on('event', instance._eventListener);
Expand Down Expand Up @@ -100,7 +102,7 @@ const createBlessedRenderer = function(blessed) {
hostContext : HostContext,
internalInstanceHandle : OpaqueHandle
) : TextInstance {
return blessed.text({content: text});
return blessed.text({content: text, screen: screenRef});
},

scheduleDeferredCallback(a) {
Expand Down Expand Up @@ -223,6 +225,8 @@ const createBlessedRenderer = function(blessed) {
const roots = new Map();

return function render(element, screen, callback) {
screenRef = screen;

let root = roots.get(screen);
if (!root) {
root = BlessedReconciler.createContainer(screen);
Expand Down

0 comments on commit dd9a920

Please sign in to comment.