use Selected Option In Url Paramutility
utility
Sets the url params to the selected option.
Was this section helpful?
Example
useSelectedOptionInUrlParam example
import {useSelectedOptionInUrlParam} from '@shopify/hydrogen-react';
const selectedOption = [
{
name: 'Color',
value: 'Red',
},
{
name: 'Size',
value: 'Medium',
},
];
useSelectedOptionInUrlParam(selectedOption);
// URL will be updated to <original product url>?Color=Red&Size=Medium
examples
Example
description
I am the default example
useSelectedOptionInUrlParam example
import {useSelectedOptionInUrlParam} from '@shopify/hydrogen-react'; const selectedOption = [ { name: 'Color', value: 'Red', }, { name: 'Size', value: 'Medium', }, ]; useSelectedOptionInUrlParam(selectedOption); // URL will be updated to <original product url>?Color=Red&Size=Medium