Skip to content

Commit

Permalink
rollback rc
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Nov 1, 2024
1 parent f6f44d6 commit b927510
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: echo "VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV

- name: SonarQube Scan (Push)
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/revert_hocs_and_render_props')
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development')
uses: SonarSource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
- name: Store assets
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/revert_hocs_and_render_props')
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development')
uses: actions/upload-artifact@v3
with:
name: assets
Expand All @@ -88,7 +88,7 @@ jobs:
name: Upload assets
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/revert_hocs_and_render_props'
if: github.event_name == 'push' && github.ref == 'refs/heads/development'
strategy:
matrix:
environment:
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for ECMAScript Modules build.
- Bugfixing - When the `config` prop is provided, the `SplitFactoryProvider` now makes the SDK factory and client instances available in the context immediately during the initial render, instead of waiting for the first SDK event (Related to https://github.com/splitio/react-client/issues/198). This change fixes a bug in the `useTrack` hook, which was not retrieving the client's `track` method during the initial render.
- BREAKING CHANGES:
- Updated the default value of the `updateOnSdkUpdate` and `updateOnSdkTimedout` parameters of the `useSplitClient` and `useSplitTreatments` hooks options object to `true`, to re-render by default when the SDK client emits the `SDK_UPDATE` or `SDK_READY_TIMED_OUT` events. The same applies for the equivalent props in the `[with]SplitClient` and `[with]SplitTreatments` components.
- Updated the default value of the `updateOnSdkUpdate` and `updateOnSdkTimedout` parameters of the `useSplitClient` and `useSplitTreatments` hooks options object to `true`, to re-render on all SDK events by default. The same applies for the equivalent props in the `[with]SplitClient` and `[with]SplitTreatments` components.
- Updated error handling: using the library modules without wrapping them in a `SplitFactoryProvider` component will now throw an error instead of logging it, as the modules requires the `SplitContext` to work properly.
- Updated the `SplitFactoryProvider` component to not accept a child as a function (render prop), to avoid unnecessary re-renders when using the library hooks. Refer to ./MIGRATION-GUIDE.md for instructions on how to migrate the child as a function to a regular component.
- Removed the `core.trafficType` option from the SDK configuration object, and the `trafficType` parameter from the SDK `client()` method, `useSplitClient`, `useTrack`, `withSplitClient` and `SplitClient` component. This is because traffic types can no longer be bound to SDK clients in JavaScript SDK v11.0.0, and so the traffic type must be provided as first argument in the `track` method calls.
Expand Down
27 changes: 27 additions & 0 deletions src/__tests__/SplitFactoryProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,31 @@ describe('SplitFactoryProvider', () => {
expect(destroySpy).not.toBeCalled();
});

test('passes attributes to the main client if provided.', () => {
(SplitFactory as jest.Mock).mockClear();
let client;

const Component = () => {
client = useSplitContext().client;
return null;
}

const wrapper = render(
<SplitFactoryProvider config={sdkBrowser} attributes={{ attr1: 'value1' }} >
<Component />
</SplitFactoryProvider>
);

expect(client.getAttributes()).toEqual({ attr1: 'value1' });

wrapper.rerender(
<SplitFactoryProvider config={sdkBrowser} attributes={{ attr1: 'value2' }} >
<Component />
</SplitFactoryProvider>
);

expect(client.getAttributes()).toEqual({ attr1: 'value2' });
expect(SplitFactory).toBeCalledTimes(1);
});

});

0 comments on commit b927510

Please sign in to comment.