JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Editor & Inputs › I’m investigating: Input and need help.
- This topic has 1 reply, 2 voices, and was last updated 12 minutes ago by
Markov.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
July 31, 2025 at 7:13 pm #112791
michaelsanders
ParticipantAre there examples of using Smart.DateRangeInput with state management in React (like Redux, Vuex, etc.)? How is data flow handled?
August 1, 2025 at 4:23 pm #112800Markov
KeymasterHi,
I prepared a React + Redux example using Smart.DateRangeInput with state management.
You can copy this as a single file for quick testing (using Create React App or Vite).Please, refer to this demo:
import React from 'react'; import ReactDOM from 'react-dom/client'; import { Provider, useSelector, useDispatch } from 'react-redux'; import { configureStore, createSlice } from '@reduxjs/toolkit'; import { DateRangeInput } from 'smart-webcomponents-react/daterangeinput'; import 'smart-webcomponents-react/source/styles/smart.default.css'; // ---------------- Redux Slice ---------------- const dateRangeSlice = createSlice({ name: 'dateRange', initialState: { value: '' }, reducers: { setDateRange: (state, action) => { state.value = action.payload; } } }); const { setDateRange } = dateRangeSlice.actions; // ---------------- Store ---------------- const store = configureStore({ reducer: { dateRange: dateRangeSlice.reducer } }); // ---------------- Component ---------------- const DateRangePicker = () => { const dispatch = useDispatch(); const dateRange = useSelector((state) => state.dateRange.value); const handleChange = (event) => { dispatch(setDateRange(event.detail.value)); }; return ( <div style={{ fontFamily: 'Arial', padding: '20px' }}> <h2>Smart.DateRangeInput + Redux Example</h2> <DateRangeInput value={dateRange} onChange={handleChange} placeholder="Select date range" style={{ width: '300px' }} /> <p style={{ marginTop: '10px' }}> <strong>Selected Range:</strong> {dateRange} </p> </div> ); }; // ---------------- App Wrapper ---------------- const App = () => ( <Provider store={store}> <DateRangePicker /> </Provider> ); // ---------------- Render ---------------- const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<App />);
Best regards,
MarkovSmart UI Team
https://www.htmlelements.com/ -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.