We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

str.match is not a function

Hello,

I have seen this error reported previously with the Splitter and I have followed all of the guidelines and updated the NPM packages to the latest versions using the ncu command. However I still get this error. I have created the most basic splitter scenario such as here:

    
    renderTest() {
        return (<div>Hello Worlddiv>)
    } 
     render (){
        return  (
                <SplitterComponent id="splitter1" height="493px" width="100%" >
                    <PanesDirective>
                        <PaneDirective content={ this.renderTest.bind(this}>
                        PaneDirective>
                    PanesDirective>
                SplitterComponent>
        )
    }

This however results in the above error. This is the same as demo code - the only thing that works in when a HTML string is supplied in the Content parameter. Help!

3 Replies

NP Narayanasamy Panneer Selvam Syncfusion Team March 11, 2020 01:23 PM UTC

Hi Sharad,

 
Greetings from Syncfusion support.

 
We have validated your requirement from the shared code example. Could you please make sure that you have closed tags properly?  
We have prepared a sample to render splitter as per your requirement. Please get it from the below link: https://stackblitz.com/edit/react-885njg-fb7iqj


In local machine if you are facing any issue with old packages, then do following steps,
 
  1. Do npm cache clean and using npm cache clean --force command.
  2. Delete package.lock.json file (if you are using yarn, then delete yarn.lock.json file)
  3. Delete node_modules folder.
  4. Now upgrade syncfusion packages to latest version using npm command. (splitter/getting-started)
Kindly let us know if still, you are facing the issue with the splitter component.
 
Regards,
Narayanasamy P.
 



SD Scott Davey November 18, 2020 08:02 AM UTC

Hi,

I am seeing this same error, and I'm using a functional component. 

I've de-duped my node_modules folder and followed all the other steps in the various forum posts.

I've traced this error into template.js in the ej2-base package. It appears the function expects a string, but the examples (and my code) are passing a function that returns a ReactElement. I've confirmed that if I rewrite the functions to return strings it works as expected.

So, my question is this — given all the examples are in React class components, what is the level of support for functional components?

Here's my example below of a functional component. If I rewrite the sidebarProvider and contentProvider functions to return HTML strings, it works, but of course I need ReactElements.

Any tips?

const MyComponent = (): ReactElement => {
    const sidebarProvider = (): ReactElement => (<div className="splitter-content">I am a sidebar</div>);
    const contentProvider = (): ReactElement => (<div className="splitter-content">I am a sidebar</div>);

    return (
        <SplitterComponent
            id="splitter"
            height="100%"
            width="100%"
        >
            <PanesDirective>
                <PaneDirective
                    size="400"
                    min="0"
                    content={sidebarProvider}
                />
                <PaneDirective
                    size="400"
                    min="0"
                    content={contentProvider}
                />
            </PanesDirective>
        </SplitterComponent>
    );
}


IS Indrajith Srinivasan Syncfusion Team November 19, 2020 12:24 PM UTC

Hi Scott, 
 
Greetings from Syncfusion support, 
 
We have validated your reported query. We have tried loading the content for the splitter as an functional component and we couldn’t find any issues with the component rendering. We have also shared the ensured sample from our end.  
 
 
Can you please check the above sample and let us know if it meets your requirements ?. If not, can you modify the above shared sample reproducing the issue and revert back to us, so that we can validate and provide solution at earliest. 
 
Regards, 
Indrajith 


Loader.
Live Chat Icon For mobile
Up arrow icon