Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Change component works in Normal React but not in SPFx

I have a root component that has:

  function aceRender(stepNum: number) {
    switch (stepNum) {
      case 1:
        return (<div><RequestStep1Body /></div>); break;
      case 2:
        return (<div><RequestStep2Body /></div>); break;
      case 3:
        return (<div><RequestStep3Body /></div>); break;
    default:       break;
  }
}
  return (
    <div ><p> Current Step {step}</p>
      <div><RequestHeader /></div>
      {aceRender(step)}
    </div>
  );

'step' is a state that when changed from the inside the 'RequestHeader' component , draws the appropriate child component 'RequestStep{n}Body' But if the state is changed from inside either RequestStep1Body, RequestStep2Body or RequestStep3Body component, the return (<div><RequestStep1Body /></div>); causes the webpart to disappear with error:

TypeError: n is not a function
    at sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70
    at t.unstable_runWithPriority (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at Bi (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at is (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at cs (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at uc (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at t.unstable_runWithPriority (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at Bi (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at lc (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)
    at Xs (sp-webpart-workbench-assembly_en-us_eec15c86d62ce90f8fe18e58491cf728.js:70)

the same code used in a React only app works fine. so I assume the issue is with SPFx.

Any one can show an SPFx example that allows for changing the appetence of component in the web part from inside a visible component? Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!