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.

No labels, initValue doesn't work

See original GitHub issue

For some reason initValue doesn’t work. No label appear even when I’ve selected a value.

Screenshot

Code:

<ModalPicker
  data={GLOBALS.FRANVARO_VALUE_LISTS.REASONS}
  initValue="Välj en anledning"
  onChange={(option) => {
    GLOBALS.FRANVARO.REASON = option.label;
    GLOBALS.FRANVARO.REASON_SELECTED = true;
  }}
/>
<ModalPicker
  data={GLOBALS.FRANVARO_VALUE_LISTS.LENGTHS}
  initValue="Välj antal timmar"
  onChange={(option) => {
    GLOBALS.FRANVARO.LENGTH = option.label;
    GLOBALS.FRANVARO.LENGTH_SELECTED = true;
  }}
/>
<ModalPicker
  data={GLOBALS.FRANVARO_VALUE_LISTS.DAYS}
  initValue="Välj en dag"
  onChange={(option) => {
    GLOBALS.FRANVARO.DAY = option.label;
    GLOBALS.FRANVARO.DAY_SELECTED = true;
  }}
/>

I had this code working before updating to RN 0.40.

The modal and picker itself is working fine. The lists are rendered as intended and the value itself is being stored correctly and is recieved by my API like intended. The only issue is the label.

Any ideas?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
tiaaaa123commented, Feb 7, 2017

WorkAround!

ModalPicker can take a children which override the default button (which doesn’t show the init value) You can give this as the child:

<View>
    <Text>{this.state.selectedValue === '' ? 'YourInitialValue' : this.state.selectedValue}</Text>
</View>

@Mjuk-Biltvatt So something like that for you

<ModalPicker
  data={GLOBALS.FRANVARO_VALUE_LISTS.REASONS}
  initValue="Välj en anledning"
  onChange={(option) => {
    GLOBALS.FRANVARO.REASON = option.label;
    GLOBALS.FRANVARO.REASON_SELECTED = true;
  }}
>
    <View>
        <Text>{this.state.selectedValue === '' ? 'YourInitialValue' : this.state.selectedValue}</Text>
    </View>
</ModalPicker>

which will display your inital value if you havent selected yet. Need some styling and you can make it as beautiful as you want 😃

0reactions
vicmpencommented, Apr 25, 2017

Thanks for this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

swift 3 error : Argument labels '(_:)' do not match any available ...
NSNumber is calling NSNumber.init( value: X ) method to instantiate a NSNumber object. "Argument labels ' (_:) ' do not match any available...
Read more >
No Labels
We are No Labels and we believe in an America where every voice counts. We believe excellent minds lie on the left and...
Read more >
Formik does not re-render when initialValues change #811
enableReinitialize still doesn't work for me. The state changes but, inner values does not changes. My code: <Formik initialValues= ...
Read more >
Working with labels - Business Central | Microsoft Learn
When Locked is set to true, the label should not be translated. Default value is false. MaxLength, Integer, Determines how much of the...
Read more >
Why {!$Label.c.myLabelName} is not working in lightning ...
Does the org where the CL does not work have a namespace? · No, there are no namespaces on both orgs.
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