-
Notifications
You must be signed in to change notification settings - Fork 42
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
fix leak on server side, not store singleton instance to global object #100
Conversation
CLA is valid! |
@@ -26,6 +25,7 @@ if ('client' === ENVIRONMENT) { | |||
* @param {Object} options.rootModelData model data of root i13n node | |||
* @param {Object} options.i13nNodeClass the i13nNode class, you can inherit it with your own functionalities | |||
* @param {String} options.scrollableContainerId id of the scrollable element that your components | |||
* @param {String} options.context context object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it clear this is the component context, and link to fluxible doc for component context.
@lingyan @redonkulus @longlho updated, please check again. |
parentI13nNode: this._i13nNode | ||
} | ||
parentI13nNode: this._i13nNode, | ||
reactI13nInstance: this._getReactI13n() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document how people can use this new context field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is internally usage, we use this context to pass reactI13n instance(and the i13n root) across components, do we want users to know this?
@lingyan @redonkulus updated, I rollbacked the breaking change, added document for the new version change, will do a |
1d9d2d7
to
9203666
Compare
@@ -27,6 +27,15 @@ var I13nDempApp = setupI13n(DemoApp, { | |||
}, [someReactI13nPlugin]); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you are missing closing back ticks for the example. This messes up formatting below.
|
||
What we do with `setupI13n` is that we will create the `ReactI13n` instance, along with a root node of the I13nTree, passing them via component context to the children. | ||
|
||
It's designed to work within React components, you should be able to just [utilFuctions](https://github.com/yahoo/react-i13n/blob/master/docs/guides/utilFunctions.md) and trigger i13n events. In case you want to do this out of React components, you can access `window._reactI13nInstance` directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be able to just use utilFunctions
updated @redonkulus @lingyan please check |
👍 |
@lingyan @redonkulus
we are storing rootI13nNode and reactI13nInstance on the global object, which causes memory leak, we are leaking all the
i13n react component
in memory on server side, because they eventually have a reference to the rootI13nNodethe solution here is just let
setupI13n
create that instance and pass it throughcontext
,so that each I13n component can still get the instance.
also rootI13nNode can just store in the reactI13n instance.
After the change, we can see there's no leaking on i13nNodes now