gabrielbull / gabrielbull/react-desktop
[Windows] Checkbox, defaultChecked issue?
- Dominant language
- JavaScript
- Stars
- 9.5k
- Forks
- 447
- PR merge metrics
- No merged PRs in 30d
Description
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](http://reactdesktop.js.org/docs/windows/checkbox)
I checked the [source](https://github.com/gabrielbull/react-desktop/blob/master/src/checkbox/windows/checkbox.js#L32), 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);)_
```javascript
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 (
{
settings.set(PREF_BOOT, e.target.value)
}}
defaultValue="I got checked!"
defaultChecked={autostartBool}
/>
);
}
}
export default Settings;
```
Contributor guide
Assessment
This issue has not been assessed yet.