-
|
Hi! I'm having trouble with the tracking/updating concepts. I have a component that isn't updating based on The component: const defaultProps = {
className: '',
disabled: false,
errorMessage: '',
onChange: () => { console.log("It's always this onChange function")},
label: '',
name: '',
placeholder: '',
value: '',
};
const FieldText = (props) => {
props = mergeProps(defaultProps, props);
const errorId = nanoid();
createEffect(() => {
console.log('props', props.onChange); // This actually ends up being the correct, intended function
})
return (
<>
<label
className='label'
htmlFor={props.name}
>
{props.label}
</label>
<input
aria-disabled={props.disabled}
aria-describedby={errorId}
className={cx(style.root, props.className)}
disabled={props.disabled}
name={props.name}
onInput={props.onChange} // Why doesn't this change?
placeholder={props.placeholder}
type='text'
value={props.value}
/>
<p
className='error'
id={errorId}
>
<screen-reader-content>Error:</screen-reader-content>
<span className='error__content'>
{props.errorMessage}
</span>
</p>
</>
);
};
export default FieldText;
What am I doing wrong here? Thanks! Edit: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
This might be of interest. I thought I mentioned it in the docs but I might have done it in a very glossed over way: I had some more discussions elsewhere. ryansolid/dom-expressions#33 (comment). From midway down to almost the end. The gist of it is that compiled consideration would de-optimize the common case and be inconsistent. Still looking if there is a reasonable solution here. |
Beta Was this translation helpful? Give feedback.
This might be of interest. I thought I mentioned it in the docs but I might have done it in a very glossed over way:
#359
I had some more discussions elsewhere. ryansolid/dom-expressions#33 (comment). From midway down to almost the end.
The gist of it is that compiled consideration would de-optimize the common case and be inconsistent. Still looking if there is a reasonable solution here.