-
Notifications
You must be signed in to change notification settings - Fork 10
Errors
All error descriptions below are related to the @gondel/core
package.
This error occurs in the
GondelComponentStarter#constructComponent
method
tbd.
This error occurs in the
GondelDomUtils#getComponentByDomNode
method
Could not find any Gondel component in namespace dedicated on a certain DOM node. This usually happens when there is no data-namespace-name
name on the node or the DOM content was modified by a third-party tool.
First check your code why the existing component could be unmounted or made unavailable. If you can't change this behaviour or prevent your application from this use the isComponentMounted()
method to check if the component is mounted.
import * as React from 'react';
import { isComponentMounted, getComponentByDomNode } from '@gondel/core';
import { Button } from './Button';
class Form extends React.Component<{}> {
private ref: HTMLButtonElement;
doSomethingWithButton() {
// check the mounting status of the Gondel component
const isButtonMounted = isComponentMounted(this.ref, Button);
if(isButtonMounted) {
// only get the component if it's available
getComponentByDomNode(this.ref, Button)._ctx.style.border = '1px solid red';
}
}
componentDidMount() {
setTimeout(() => {
this.ref.remove();
}, 300);
}
render() {
<button
data-g-name="Button" {/* this is important! */}
ref={(ref: HTMLButtonElement) => this.ref = ref}>
</button>
}
}
This error occurs in the
GondelDomUtils#getComponentName
method
The component which is beeing used does not have a mapping to the dedicated namespace.
Register the component in all used namespaces.
import { GondelBaseComponent, Component, getComponentByDomNode } from '@gondel/core';
@Component('OnlyScoped', 'scoped')
class OnlyScoped extends GondelBaseComponent {}
@Component('ScopedGlobal)
@Component('ScopedGlobal, 'scoped')
class ScopedGlobal extends GondelBaseComponent {}
// this will throw the error because OnlyScoped does not have
// a mapping for the namespace 'g' (default)!
getComponentByDomNode(someNode, OnlyScoped);
// this will work!
getComponentByDomNode(someNode, ScopedGlobal);
getComponentByDomNode(someNode, ScopedGlobal, 'scoped');
getComponentByDomNode(someNode, OnlyScoped, 'scoped');
This error occurs in the
GondelDomUtils#getComponentName
method
This issue occurs if the component class is missing the static private value __identification
which defines its mapping to different namespaces. The value is set by the @Component
decorator and/or by the GondelBaseComponent
base class.
Make sure you use the @Component
decorator and extend the GondelBaseComponent
. If you're using ordinary JavaScript and not typescript and won't extend the GondelBaseComponent
class, provide a static object __identification
in your class.
import { registerComponent } from '@gondel/core';
class MyComponent {
someMethod() {
return 'Some value!';
}
}
// provide the identification map
MyComponent.__identification = {};
registerComponent('MyComponent', MyComponent, 'myNamespace');
This error occurs in the
GondelDecorators#EventListener
method
Invalid handler name '${handler}' use '_${handler}' instead.
This error occurs in the
GondelEventEmitter#triggerPublicEvent
method.
The event you'd like to trigger may not be valid in terms of Gondel's event guidelines.
Make sure your public event starts with the namespace of the component, followed by the event. The string must be written camelCase.
import { GondelBaseComponent, Component } from '@gondel/core';
@Component('MyComponent', 'myNamespace')
class Something extends GondelBaseComponent {
_triggerPublicEvent() {
// wrong, doesn't use the right namespace/convention
triggerPublicEvent('myEvent');
triggerPublicEvent('myNamespacemyEvent');
// this is the correct way!
triggerPublicEvent('myNamespaceMyEvent');
}
}
This error occurs in the
GondelPluginUtils#fireGondelPluginEvent
method
Make sure your plugin does not return a promise or basically work asynchron.
interface IWorksData {
multiplier: number
}
const works = (val: number, data: IWorksData, done: (result: number) => number) => {
done(val * data.multiplier);
};
const doesNotWork = (val: number, data: IWorksData, done: (result: number) => number) => {
setTimeout(done.bind(null, [val * data.multiplier]), 1000);
};
This means your extended GondelReactComponent
does not have a render method which causes the error.
Add a public method render()
to your custom component.
import * as React from 'react';
import { GondelReactComponent } from '@gondel/plugin-react';
// this will fail, because render method is missing
class Fails extends GondelReactComponent<any> {
doSomething() {}
}
class Works extends GondelReactComponent<any> {
public render() {
return <h1>Hello World!</h1>
}
}
The smallest provided viewport must not be set to Infinity. This should only happen if the user did a miss configuration with only a single breakpoint which is set to Infinity
.
Provide a valid configuration with valid breakpoints.
import { initMediaQueriesPlugin } from '@gondel/plugin-media-queries';
// this will cause an error because only breakpoint
// defined is set to Infinity.
initMediaQueriesPlugin({
breakPoints: {
xxlarge: Infinity,
}
});
// works!
initMediaQueriesPlugin({
breakPoints: {
xxsmall: 480,
xxlarge: Infinity,
}
});
© Namics AG