Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Checkbox, defaultChecked issue? #90

Open
codekidX opened this issue Jul 26, 2017 · 1 comment
Open

[Windows] Checkbox, defaultChecked issue? #90

codekidX opened this issue Jul 26, 2017 · 1 comment
Labels

Comments

@codekidX
Copy link

Hi, I have successfully integrated other components into my electron app and it's working great, Thank you.

I think there is some issue with defaultChecked property of checkbox in Windows. Is it of type string ? as mentioned in docs

I checked the source, it checks if value and type is strictly boolean.

I'm totally new to react and electron development, if you could help me with issue it'd be great. Here is my full code: (Do read the comment below console.log(autostartBool);)

import React from 'react';
import styled from 'styled-components';
import { Checkbox } from 'react-desktop/windows';
// electron variables
const settings = require('electron-settings');

const PREF_BOOT = 'boot';

// Preferences
var autostartBool = false;

function checkIfPrefsAreInitialized() {
  if(!settings.has(PREF_BOOT)) {
    settings.set(PREF_BOOT, autostartBool);
  }
}


class Settings extends React.Component {

constructor(props) {
    super(props);

    // ====== PREF =============
    // At start (first time ever) if user will not have these prefs so ..
    // JUST SET IT !!
    checkIfPrefsAreInitialized();


    autostartBool= settings.get(PREF_BOOT);

    console.log(autostartBool); 
    // For some reason it prints "I got checked!" 
    // which is the defaultValue of Checkbox BUT the checkbox is not checked by default


}


  render() {
    return (
    	    	 <Checkbox
        color={this.props.color}
        theme={this.props.theme}
        label="Automatically start Linkcue on boot"
        onChange={(e) => {
        	settings.set(PREF_BOOT, e.target.value)
        }}
        defaultValue="I got checked!"
        defaultChecked={autostartBool}
      />
    );
  }
}

export default Settings;
@gabrielbull
Copy link
Owner

Please submit a PR and we will accept it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants