question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Toggle component Type error

See original GitHub issue

Hey Claudio! I’ve got one for ya 😃

I’m using your mobx-react-form nested fields Demo, in rfx-stack. I added more fields to the members[].hobbies[] nested field.

The problem is the field type is not being detected as Boolean unless I set a value for that field. Since it is nested, and I can add more fields, as soon as I click + to add a fieldset with the Toggle element, I get props errors because mobx-react-form sets the value as a blank string, instead of false. And thus when I click the Toggle it does not work or set correct value from form state.

Warning: Failed prop type: Invalid prop switched of type string supplied to EnhancedSwitch, expected boolean.

The documentation only mentions in using Separated Properties method of initializing fields I can pass in a defaults and types, but without any example of formatting I am lost. I tried using members[].hobbies[] formatting and also as a nested object, with no luck. I wish to use Boolean for the checkbox value as material-ui requires, so that I may also align the type with my feathers/mongoose API schema as Boolean also.

I hope I am making sense! I can show example code or repo if you need.

Rich

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
richieiocommented, Feb 5, 2017

Yesss you rock!!!

1reaction
foxhound87commented, Feb 5, 2017

No bother! Hope this fix should work. Let me know if you encounter other issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript Error for toggle component #1401 - GitHub
Type 'EventEmitter<ToggleChange>' is not assignable to type 'EventEmitter<CheckboxChange>'. Types of property 'observers' are incompatible. Type ...
Read more >
TypeError: Cannot read property 'toggle' of undefined
I want to pass a function as a prop to this component, but something doesn't work properly and I don't know. render() {...
Read more >
Switch - React Native
Switch. Renders a boolean input. This is a controlled component that requires an onValueChange callback that updates the value prop in order ...
Read more >
Flow Screen Input Component: Toggle - Salesforce Help
Let users flip a toggle in a flow screen.Required Editions Available in: both Salesforce Classic and Lightning Experience Available in: Essentials, Profes.
Read more >
Documentation - Toggle Switches - Clarity Design System
Helper and error messages. To leverage helper and validation messages, you'll need to wrap all of the toggle switches inside of a ClrToggleContainer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found