Skip to content
Discussion options

You must be logged in to vote

I think I've got it finally (consider that this is my first time to deal with React code):
This colorPickerField initializes with the defaultValue from where the field is used and saves the new color in a preference using it's path within the payload collection as a key ('colors.primary').
I'm pretty happy now.

const colorPickerField = (args) => {
  // payload:
  // args.name: "primary"
  // args.path: "colors.primary"
  // args.defaultValue: "#74ea94"
  const { path, label, required } = args
  const { value, setValue } = useField({ path })
  const { getPreference, setPreference } = usePreferences()
  // react:
  const [color, setColor] = useState(args.defaultValue)

  useEffect(() => {
    

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@unonweb
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by unonweb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant