Category : mobx

class EditLocation extends Component { constructor(props) { super(); this.state = { LocationId: ”, locationOptions: [], } this.baseState = this.state; this.findLocationById = this.findLocationById.bind(this); } findLocationById = (locationId) => { let locationOptions = []; if (locationId <= 0) { setTimeout(()=>{ this.setState(this.baseState); locationOptions.push( <CustomInput type="checkbox" id={value.LocationTypeId} key={value.LocationTypeId} value={value.LocationTypeId} defaultChecked={false} label={`${value.LocationTypeName}`} className="mb-0" onChange={this.handleCheckbox.bind(this)} /> ) this.setState({locationOptions:locationOptions}) },200) else { ..

Read more

I have the following mobx store: import $ from ‘jquery’; import { observable, action, computed, reaction } from ‘mobx’; class AvailabilityCallendar { public function __construct(){ } @observable selected_date = new Date(); @observable max_persons = 2; @observable loading = false; @observable availableDates = null; // initial value, it may be any valid js value. async getAvailableDate() ..

Read more

In my project I have the following mobx store: class AvailabilityCallendar { @observable selected_date = new Date(); @observable max_persons = 2; @observable loading=false; @computed get availableDate(){ $.ajax({ url: createUrl(‘/calendar/availability’)+"persons="+this.max_persons+’&’+selected_date.format(‘yy-m-d’), type: ‘GET’, beforeSend: function(){ this.loading = true; }, success: function(data){ // return value here }, fail: function(jqXHR, textStatus, errorThrown){ this.loading=false; console.error("Error: " + errorThrown + ", ..

Read more

I recently got headcache with my website was very slow to load. it caused i load 4 data when componentDidMount execute. the problem is.. how can i do the fetch only when i click the onChange?.. i use mobX for state management.. heres my code componentDidMount : componentDidMount = () => { this.props.mainStore.getProvinsi(); this.props.mainStore.getKab(); this.props.mainStore.getKec(); ..

Read more

I have a Dark Mode component which is a simple toggle between Sun & Moon icons. DarkMode.tsx import { observer } from ‘mobx-react’ import { MoonIcon, SunIcon } from ‘@heroicons/react/solid’ import { useStore } from ‘@/store/index’ export const DarkMode = observer(() => { const { theme, setTheme, isPersisting } = useStore() if (!isPersisting) return null ..

Read more