File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ export function createContext(defaultValue, contextId) {
1818 /** @type {FunctionComponent } */
1919 Provider ( props ) {
2020 if ( ! this . getChildContext ) {
21- /** @type {Component[] | null } */
22- let subs = [ ] ;
21+ /** @type {Set< Component> | null } */
22+ let subs = new Set ( ) ;
2323 let ctx = { } ;
2424 ctx [ contextId ] = this ;
2525
@@ -31,19 +31,19 @@ export function createContext(defaultValue, contextId) {
3131
3232 this . shouldComponentUpdate = function ( _props ) {
3333 if ( this . props . value !== _props . value ) {
34- subs . some ( c => {
34+ subs . forEach ( c => {
3535 c . _force = true ;
3636 enqueueRender ( c ) ;
3737 } ) ;
3838 }
3939 } ;
4040
4141 this . sub = c => {
42- subs . push ( c ) ;
42+ subs . add ( c ) ;
4343 let old = c . componentWillUnmount ;
4444 c . componentWillUnmount = ( ) => {
4545 if ( subs ) {
46- subs . splice ( subs . indexOf ( c ) , 1 ) ;
46+ subs . delete ( c ) ;
4747 }
4848 if ( old ) old . call ( c ) ;
4949 } ;
You can’t perform that action at this time.
0 commit comments